 	/*
	 *
	 * Copyright	: 	Confidential and Proprietary. 
	 *					Copyright CMP Media, 2006
	 *									
	 * File name	:	esdscripts.js 
	 *
	 * Description	:	This js contain methods related to Embedded Systems.
	 * 					
	 * Author		:	Cognizant
	 *
	 * Date			:	Aug 12, 2006
	 *
	 * Modification History		
	 *
	 * Revision No.	  Author		   Date				 Comments
	 *
	 * 1.0			  Cognizant 	   Aug 12, 2006		 Initial Version
	 * 
	 * 1.1			  Cognizant        May 10, 2007	     1.Disabling the submit
	 *                                                     button when clicked 
	 *                                                     once in subscription
	 *                                                     pages 
	 * 1.4             Cognizant       May 24, 2007   1. ESD form change
	 *                                                   (question format change)	  
	 */
var SubmitFlag = false;
var complete = false;

function OfferPageNoClicked() {

	document.forms[1].submit();
}
function freeOnClick()
{
	if (confirm("You have indicated that you do not wish to receive " +
	"ESD Magazine. If this is an error, please click the Cancel button to"+
	" return to the ESD Magazine form."))
	{
	document.forms[0].Free[0].checked = true;
	SubmitFlag = true;
	window.location = "http://www.embedded.com/";
	}
	else
	{
		document.forms[0].Free[0].checked = true;
		document.forms[0].Free[1].checked = false;
	}
}

function freeOnClickTele()

{

      if (confirm("You have indicated that you do not wish to receive " +
      "Embedded Systems Design Magazine. If this is an error, please click the " 
      + "Cancel button to return to the Embedded Systems Design Magazine form."))

      {

      SubmitFlag = true;
      window.location = "http://www.embedded.com/";

      }

      else

      {
            document.forms[0].teleRequest[0].checked = true;
            document.forms[0].teleRequest[1].checked = false;

      }

}

function openWindow(path,width,height,t,l,s,r)
{
	var w = screen.width;
	var h = screen.height;
	var left = (w - width) / 2;
	var top = (h - height) / 2;
	var args = "toolbar=" + t + ",location=" + l + ",scrollbars=" +
		s + ",resizable=" + r + ",width=" + width + ",height=" +
		height + ",left=" + left + ",top=" + top;
	seWin = window.open(path,"esd",args);
	seWin.focus();
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e)
{
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele)
	{
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
		found = true;
		else
		index++;
		return found;
	}
	function getIndex(input)
	{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
	return true;
}

function ConfirmQuit()
{
	var l_bFlag;
	if (SubmitFlag == true || complete == true)
		{
			SubmitFlag="false";
			return;
		}
	else
		{
			return "Embedded Systems Design is FREE to qualilfied key designers responsible for defining systems, selecting the critical hardware and software components, building the systems, and integrating the hardware and firmware designs --- but you must complete the entire form. If you are selected,you will receive a FREE subscription (others pay $55 per year)";
		}
}

function confirmQuit()
{
	var l_bFlag;
	if (SubmitFlag == true || complete == true)
		{
			SubmitFlag="false";
			return;
		}
	else
		{
			return "Embedded Systems Design is FREE to qualilfied key designers responsible for defining systems, selecting the critical hardware and software components, building the systems, and integrating the hardware and firmware designs --- but you must complete the entire form. If you are selected,you will receive a FREE subscription (others pay $55 per year)";
		}
}

// Version 1.1 - Comment 1 - Start
// Commented to use it as common method
/*
function doSubmit()
{ 
   SubmitFlag = true; 
    return true; 
  }  
*/
// Version 1.1 - Comment 1 - End

function WindowClose() {			
		window.close()
		}
		
function showLongFormat(title1, long){
		<!-- linklongpopup = linklongpopup+"&forward=longformatdetails"; -->
		var linklongpopupactual = linklongpopup;
		// alert(linklongpopup);
		linklongpopup = linklongpopup + "&title=" + title1 + "&long=" + long;
				// alert(linklongpopup);
		window.open(linklongpopup,'Popuplongformat','left=180,top=225,width=550,height=200,toolbar=0,resizable=0,scrollbars=1');
		
		linklongpopup = linklongpopupactual;
}

function showinPopup(offerId){

		var linklongpopupactual = linklongpopup;

		linklongpopup = linklongpopup + "&LeagGenOfferId=" + offerId;
				// alert(linklongpopup);
		window.open(linklongpopup,'Popuplongformat','left=180,top=225,width=550,height=200,toolbar=0,resizable=0,scrollbars=1');
		
		linklongpopup = linklongpopupactual;	
}


/*
*  version 1.3 comment1 start
*/
 function submitFlag() 

  { 
    
    doSubmit();       
    othertextbox1();

  }
  
  
  
function othertextbox1() {

        SubmitFlag = true; 
       if(document.forms[0].QID_9011[10].checked) {
                  if(document.forms[0].OTHER$9012$901211.value != "") {
                        document.forms[0].OTHER$9011$901111.value=document.forms[0].OTHER$9012$901211.value;
                  } 
      }


  }
  
/*
*  version 1.3 comment1 End
*/