var newWindow
var core_index
var model_index
var info_index
var input_string
var requested_core = " "

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function dpSmartLink(u,n,w,h,p) { // v1.4 by David Powers
  var a,j,k,x,y,f='';if(!n){n='';}if(w){f+='width='+w+',';}if(h){f+='height='+h+',';}
  if(p){p=p.split(':');if(p[0]!='z'){p[0]=='c'?(x=(screen.width-w)/2):x=p[0];f+='left='+x+',';}
  if(p[1]!='z'){if(p[0]=='c'){y=(screen.height-h-p[1])/2;if(navigator.appName.indexOf('Op')!=-1){
  y-=96;y=y<0?0:y;}}else{y=p[1];}f+='top='+y+',';}}a=arguments.length;if(a>5){for (k=5;k<a;k++){
  switch(arguments[k]){case 'all':f+='toolbar,menubar,location,scrollbars,status,resizable,';break;
  case 't':f+='toolbar,';break; case 'm':f+='menubar,';break;case 'l':f+='location,';break;
  case 'sc':f+='scrollbars,';break;case 's':f+='status,';break;case 'r':f+='resizable,';}}}
  if(f.charAt(f.length-1)==','){f=f.slice(0,-1);}j=window.open(u,n,f);j.focus();
  document.MM_returnValue=false;
}

function P7_getHW(t,a) { //v2.03 by PVII
  var r,p,h=0,w=0;if((p=MM_findObj(a)) !=null){
  if(document.all || document.getElementById){h=parseInt(p.offsetHeight);w=parseInt(p.offsetWidth);
  if(!h){h=parseInt(p.style.pixelHeight);w=parseInt(p.style.pixelWidth);}
  }else if(document.layers){h=parseInt(p.clip.height);w=parseInt(p.clip.width);}}
  if(t=="width"){r=w;}else{r=h;}return r; 
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  newWindow = window.open(theURL,winName,features);
  newWindow.focus();
  return(newWindow);
}


function closeNewWindow()
{
	if (newWindow) {
		newWindow.close();
		newWindow = null;
	}
}

function set_page_variables() {

core_index = 0;
model_index = 0;
info_index = 0;

input_string = document.location.toString();

if (input_string.indexOf("cores/index") >= 0){
 core_index = 1;
 MM_nbGroup('over','cores','file:///C|/graphics/nav/coresbtn_f2.gif','',1);
 check_core_page();
 }
if (input_string.indexOf("models/index") >= 0) model_index = 1;
if (input_string.indexOf("info/index") >= 0) info_index = 1;

}
function check_core_page(){
if (core_index == 1) {

MM_showHideLayers('coresmenu','','hide','modelsmenu','','hide','infomenu','','hide','cores2','','show');
}
else
{
MM_showHideLayers('coresmenu','','show','modelsmenu','','hide','infomenu','','hide','cores2','','hide');
}
}










function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}


function findRequestingCore(){
	var handyString = location.search;
	var startOfSource=handyString.indexOf("corename=");
	if (startOfSource != -1) {
	var endOfSource = handyString.indexOf("&",startOfSource+9);
	var result = handyString.substring(startOfSource+9,endOfSource);
	}
	else
	{
	var result = "";
	}
	
	return result
	}
	
	
	function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
	
	function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
	
	function submit_altera_opencore_Form2(coreInfoForm){
	
	submitForm(coreInfoForm);
	var radioset;
	radioset = false;
	if (coreInfoForm.altera_id[0].checked){
	radioset = true;
	if (coreInfoForm.NIC.value == ""){
	alert('A valid identification number is required.\n');
	return(false);
	}}else if (coreInfoForm.altera_id[1].checked){
	radioset = true;
	if (coreInfoForm.Host_Id.value == ""){
	alert('A valid identification number is required.\n');
	return(false);
	}}else if (coreInfoForm.altera_id[2].checked){
	radioset = true;
	if (coreInfoForm.Disk_Serial_Number.value == ""){
	alert('A valid identification number is required.\n');
	return(false);
	}}else if (coreInfoForm.altera_id[3].checked){
	radioset = true;
	if (coreInfoForm.Guard_Id.value == ""){
	alert('A valid identification number is required.\n');
	return(false);
	}}else if (coreInfoForm.altera_id[4].checked){
	radioset = true;
	if (coreInfoForm.License.value == ""){
	alert('A valid identification number is required.\n');
	return(false);
	}}
	if (radioset == false){
	alert('A valid identification number is required.\n');
	return(false);
	}
	MM_validateForm('First_Name','','R','Last_Name','','R','Cores','','R','Email','','RisEmail','Phone','','R','Company','','R','Core_Name','','R','Altera_Device_Name','','R');
	
	return document.MM_returnValue;
	
	}
	
	
	function submit_altera_opencore_Form(coreInfoForm){
	
	submitForm(coreInfoForm);
	MM_validateForm('First_Name','','R','Last_Name','','R','Cores','','R','Email','','RisEmail','Phone','','R','Company','','R','Core_Name','','R','Altera_Device_Name','','R','Quartus_Version','','R','NIC','','R','Host_Id_Serial_Number','','R','Guard_Id_License','','R');
	
	return document.MM_returnValue;
	
	}
	
	function reset_altera_ids(){
	
	
	
	document.opencore_request.NIC.value = "";
	document.opencore_request.NIC.disabled=true;
	document.opencore_request.NIC.style.backgroundColor='#cccccc';
	document.opencore_request.Host_Id.disabled=true; 
	document.opencore_request.Host_Id.value = "";
	document.opencore_request.Host_Id.style.backgroundColor='#cccccc';
	document.opencore_request.Disk_Serial_Number.disabled=true;
	document.opencore_request.Disk_Serial_Number.value = "";
	document.opencore_request.Disk_Serial_Number.style.backgroundColor='#cccccc';
	document.opencore_request.Guard_Id.disabled=true;
	document.opencore_request.Guard_Id.value = "";
	document.opencore_request.Guard_Id.style.backgroundColor='#cccccc';
	document.opencore_request.License.disabled=true;
	document.opencore_request.License.value = "";
	document.opencore_request.License.style.backgroundColor='#cccccc';
	
	
	}
	
	function formReset(){
	alert("in formReset again");
	document.newsletter_request.user_phone.value = "";
	alert("in formReset again again");
	}

function submit_synplicity_Form(synplicityForm){
	
	
	
	MM_validateForm('name','','R','company','','R','country','','R','email','','RisEmail','phone','','R','zip','','R');
		
	return document.MM_returnValue;
	
	}
	
	
	function submit_core_query_Form(coreInfoForm){
	
	submitForm(coreInfoForm);
	
	MM_validateForm('First_Name','','R','Last_Name','','R','Cores','','R','Email','','RisEmail','Phone','','R','Company','','R');
		
	return document.MM_returnValue;
	
	}
	
	function submit_meeting_request(coreInfoForm){
	
	expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()+6);
	document.cookie = "firstName="+escape(coreInfoForm.First_Name.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "lastName="+escape(coreInfoForm.Last_Name.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "company="+escape(coreInfoForm.Company.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "email="+escape(coreInfoForm.Email.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Title="+escape(coreInfoForm.Title.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Address1="+escape(coreInfoForm.address1.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Address2="+escape(coreInfoForm.address2.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "City="+escape(coreInfoForm.city.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "State="+escape(coreInfoForm.state.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Zip="+escape(coreInfoForm.zip.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "phone="+escape(coreInfoForm.Phone.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "country="+escape(coreInfoForm.Country.value)+";expires=" + expireDate.toGMTString();
		  	
	
	
	MM_validateForm('First_Name','','R','Last_Name','','R','Email','','RisEmail','Phone','','R','Title','','R','Company','','R','First_Choice_Meeting_Time','','R','Second_Choice_Meeting_Time','','R','Project_Description','','R');
		
	return document.MM_returnValue;
	
	}
	function submitForm(coreInfoForm){
	
	
	expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()+6);
	document.cookie = "firstName="+escape(coreInfoForm.First_Name.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "lastName="+escape(coreInfoForm.Last_Name.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "company="+escape(coreInfoForm.Company.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "email="+escape(coreInfoForm.Email.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Title="+escape(coreInfoForm.title.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Address1="+escape(coreInfoForm.address1.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Address2="+escape(coreInfoForm.address2.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "City="+escape(coreInfoForm.city.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "State="+escape(coreInfoForm.state.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "Zip="+escape(coreInfoForm.zip.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "phone="+escape(coreInfoForm.Phone.value)+";expires=" + expireDate.toGMTString();
	document.cookie = "country="+escape(coreInfoForm.Country.value)+";expires=" + expireDate.toGMTString();
		  	
	
	}
	
	function GetCookie (name){
	var result="";
	var myCookie = " " + document.cookie + ";";
	
	var searchName = " " + name + "=";
	
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1) {
	startOfCookie += searchName.length;
	endOfCookie = myCookie.indexOf(";",startOfCookie);
	result=unescape(myCookie.substring(startOfCookie,endOfCookie));
	
	}
	return result;
	}
	
	
	var user;
var domain;
var suffix;
function hideem(user, domain, suffix){
document.write('<a href="' + 'mai' + 'lto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}


function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

