
// Function to open links marked with rel="external" in new window.
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
//window.onload = externalLinks;


// Generic pop up window open function.
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  			window.open(theURL,winName,features);
	}

// Newsletter pop up
	function newsletterPopup(theURL,winName) { 
  			window.open(theURL,winName,'width=700,height=600,scrollbars=yes');
	}


// Function to open print dialog.
	function printIt() {
	 		if(print())
					print();
  	}


// Filter devices on device matrix page
function filterDevice() {
		target = document.sort.deviceSearch.options[document.sort.deviceSearch.selectedIndex].value;
		document.location = target;
	}

// Functions needed in tool pages

function selectProduct(target) {
    if (target != "") {
        document.location = target;
    }
}

// download of single file (tool page)
function singleFile2() {

    var parameter = document.version.fileUri.value;
    var split = parameter.lastIndexOf('*');
    var fileName = parameter.substring(split+1, parameter.length);
    var path = parameter.substring(0, split); 

    var DLMethod1 = "a";

    if(document.version.downloadMethod[0].checked) { DLMethod1 = "s"; }

    if(DLMethod1 == "a") {startdm(path, fileName); } else { document.location = path; }
}

// download of multiple file (tool page)
function getDLMethod() {

    var parameter = document.version.fileId.options[document.version.fileId.selectedIndex].value;
    var split = parameter.lastIndexOf('*');
    var fileName = parameter.substring(split+1, parameter.length);
    var path = parameter.substring(0, split);

    var DLMethod = "a";

    if(document.version.downloadMethod[0].checked) { DLMethod = "s"; }
    if(DLMethod == "a") { startdm(path, fileName); } else { document.location = path; }
}

// download with download manager (tool page)
function startdm(uri, fileName) {

    var now = new Date();
    var windowName = now.getFullYear() + "" + now.getMonth() + "" + now.getDate() + "" + now.getHours() + "" + now.getMinutes() + "" 
+ now.getSeconds();
    var url="/dynamic/download_manager.html?url=" + uri + "&filename=" + fileName;
    //var url = "/downloadmanager/check_disc2?URI=" + uri + "&btype=" + escape(checkSystem());

    
MM_openBrWindow(url,windowName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=420,height=330");
}

// request serila number (tool page)
function requestSerial() {
    var fileId = "";
    if (document.version.fileIdSerial) {
        var parameter = document.version.fileIdSerial.options[document.version.fileIdSerial.selectedIndex].value;
        var split = parameter.indexOf('-');
        var productName = parameter.substring(0,split);
        var productVersion = parameter.substring(split+1,parameter.length);
    } else {
        alert("Failed");
    }
    var url = "/product_request_serial?productName=" + productName + "&productVersion=" + productVersion;
    if (url != "") {
        document.location = url;
    }
}

function getGenericURI() {
    var id = document.getElementById('linkURL');
    var parameter = document.version.fileId.options[document.version.fileId.selectedIndex].value;
    var split = parameter.lastIndexOf('*');
    var path = parameter.substring(0, split);
    
    id.href = path;
}

