function CheckSerialNumber(sn)
{
	alert('Buy now___:'+sn);
	var filter=/^([a-zA-Z0-9]){25,40}$/i
    
	if (filter.test(sn)) 
	{
	 var sec_filter = /^(?=.*[0-9])(?=.*[a-zA-Z]).{4,40}$/i
	 
	 if (sec_filter.test(sn))  	
	               return true;
	 return false;
	}
	return false;
}

function delayDownload(htmlID,iframesrc,srcfilename)
{
// optionaly : add thank dowalod message....
  document.getElementById(htmlID).innerHTML += '\<iframe id="ifr" style="visibility:hidden" src="'+iframesrc+'" ><\/iframe>'; 
  setTimeout('onTimer("'+srcfilename+'")',300);
}

function onTimer(filename)
{
  window.location = filename ;
}
 
function LogStatandSubmit(htmlID,iframesrc,fromID)
{
// optionaly : add thank dowalod message....

 
 //setTimeout('onFromTimer("'+htmlID+'")',300);	
  
  
  document.getElementById(fromID).submit();
  document.getElementById(htmlID).innerHTML += '\<iframe id="iffr" style="visibility:hidden" src="'+iframesrc+'" ><\/iframe>';
}

function onFromTimer(htmlID)
{
 
  
   document.getElementById(htmlID).innerHTML += '\<iframe id="iffr"   src="'+iframesrc+'" ><\/iframe>'; 
}


// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 SwapSubMenuDisplay(id_name,nSubs)
{
	for (i=1;i<=nSubs;i++)
	 {
		if ( document.getElementById(id_name+i).style.display == 'none' 
									 || document.getElementById(id_name+i).style.display == '' )
		   document.getElementById(id_name+i).style.display = 'block';
		else document.getElementById(id_name+i).style.display = 'none';
	 } 
}

function ChangeDelaySrcImg(img,src,loadImg){
  img.src = loadImg ; 
  setTimeout('ChangeSrcImg(\''+img.id+'\',"' + src + '")',800 );
 }
 
function ChangeSrcImg(id,src){
  src=src+"?dummy="+Math.random();
 document.getElementById(id).src = src ;
 
 }

function MakeUpper(id){
  
 document.getElementById(id).value =document.getElementById(id).value.toUpperCase(); 
 
 }
 
function changeClassStyle(id,nClassName){
	document.getElementById(id).className = nClassName;
}

function checkDownloadsfields()
{
 var wasEmpty = false;
          if ( document.f1['email'].value   =='' ) 
		  {
			  changeClassStyle('email',"EmptyField");
		      wasEmpty = true; 
		  }
		  else changeClassStyle('email',"");
		  
		  if ( document.f1['serial'].value  =='' || document.f1['serial'].value=='write here your device serial number.'){
			  changeClassStyle('serial',"EmptyField");
			  wasEmpty = true; 
		  }
		  else changeClassStyle('serial',"");
		  
		  if ( document.f1['name'].value    =='' ){
			  changeClassStyle('name',"EmptyField");
			  wasEmpty = true; 
		  }
		  else changeClassStyle('name',"");
		  
		  if ( document.f1['code'].value    =='' ){
			  changeClassStyle('code',"EmptyField");
			  wasEmpty = true; 
		  }
		  else changeClassStyle('code',"");
		  
		  if ( document.f1['screen'].options[document.f1['screen'].selectedIndex].value =='-1' ) {               changeClassStyle('screen',"EmptyField") 
		       wasEmpty = true; 
		  }
		  else changeClassStyle('screen',"");
		  
		  
		       
 
      if (wasEmpty){
		  alert ('Please fill all required fields!');
	      return false;
	  }
		
	return true;	
}

function show(id,bshow){
 if (bshow)
   document.getElementById(id).style.display='';
 else document.getElementById(id).style.display='none';
}

function showList(ids,bshow){
for ( x in ids) show(ids[x],bshow) ;
}

function fixClassList(ids,mc1assName){
for ( x in ids) 
 document.getElementById(ids[x]).className=mc1assName;
}

function swapshow(x){
if (document.getElementById(x).style.display=='none')
document.getElementById(x).style.display='';
else document.getElementById(x).style.display='none';
}

function shichImg(x,img1,img2){
	if (document.getElementById(x).src.search(img1) != -1 )
	    document.getElementById(x).src=img2;
	else 
    	document.getElementById(x).src=img1;
	}

function shwichClass(x,c1,c2){
//document.write(	document.getElementById(x).className );
if (document.getElementById(x).className==c1)
document.getElementById(x).className=c2;
else document.getElementById(x).className=c1;
}



function checkBuyfields()
{
 var wasEmpty = false;
    
          if ( document.fb1['email1'].value   =='' || document.fb1['email1'].value != document.fb1['email2'].value ) 
		  {
			  changeClassStyle('email1',"EmptyField");
			  changeClassStyle('email2',"EmptyField");
		      wasEmpty = true; 
		  }
		  else
		  {
			  changeClassStyle('email1',"");
			  changeClassStyle('email2',"");
		  }
		  
		  if ( document.getElementById("cab").checked )
		  {
		  
			  if ( document.fb1['serial'].value  =='' || document.fb1['serial'].value=='write here your device serial number.'){
				  changeClassStyle('serial',"EmptyField");
				  wasEmpty = true; 
			  }
			  else changeClassStyle('serial',"");
			  
			  if ( document.fb1['screen'].options[document.fb1['screen'].selectedIndex].value =='-1' )
			  {              
			  changeClassStyle('screen',"EmptyField") 
		       wasEmpty = true; 
		      }
		      else changeClassStyle('screen',"");
		  
		  }
		  
		   var S_Params = Array('creditCardType','expDateMonth','expDateYear','state','country');
   for ( x in S_Params )
    if ( document.fb1[S_Params[x]].options[document.fb1[S_Params[x]].selectedIndex].value == '-1'
	  || document.fb1[S_Params[x]].options[document.fb1[S_Params[x]].selectedIndex].value == '')
		  {              
		  changeClassStyle(S_Params[x],"EmptyField") 
		   wasEmpty = true; 
		  }
		  else changeClassStyle(S_Params[x],"");
	  
		  var params = Array('firstName','lastName','creditCardNumber','cvv2Number','address1','city','zip');
		  
		 for ( x in params )
			 if ( document.fb1[params[x]].value  =='' ){
				  changeClassStyle(params[x],"EmptyField");
				  wasEmpty = true; 
			  }
			  else changeClassStyle(params[x],"");
		  
		
	
      if (wasEmpty){
		  alert ('Please fill all required fields!');
	      return false;
	  }
	
    
	document.getElementById("formZone").style.display = 'none' ;
	document.getElementById("resZone").style.display = '' ;
	document.getElementById("resZone").innerHTML = '<img src="../../images/load.gif"><br>Please Wait...<br><br><br><br>';
  
	document.fb1.submit();	
	return true;	
}

// for Doenload demo - set dowonload button state (enable/disable)
function OnchangeCombo( ) 
{
if (document.getElementById('lang').value!="-1"  && document.getElementById('type').value!="-1")
document.getElementById('button').disabled=false;
else
document.getElementById('button').disabled=true;
}


function getWindowsHeight()
{
	if ( typeof( window.outerHeight ) == 'number' )  
	  return window.outerHeight;
	
	return 	document.documentElement.clientHeight;
}

function getWindowsWidth()
{
	if ( typeof( window.outerWidth) == 'number' )  
	  return window.outerWidth;
	
	return 	document.documentElement.clientWidth;
}




function isValidMail(str)
{
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return (filter.test(str));
}

function isRegexMath(str,filter_)
{
	var filter=/^$/i
	filter.compile(filter_);
	if (filter.test(str)) return true;
	return false;
}

function PreloadImage(imageUrl,handle) { 
  handle = new Image;
  handle.src = imageUrl;
}