/*	Print Version	*/
var currentPageID = 0;
var searchValue = "";

function CreatePrintVersionLink()
{
	var WinPrint = window.open('PrintVersion.aspx?pageID=' + currentPageID + '&search=' + searchValue);
	WinPrint.print();
}

function setJavaPageID(id, searchVal)
{
	currentPageID = id;
	searchValue = searchVal;
}



/*	Search */
function activateSearchButtonOnEnter()
{
	var key = event.keyCode;
	if(key == 13)
	{
		window.location='search_' + document.getElementById('searchInput').value+ '.html';
	}
}


/*	Open Big Picture	*/
function enlargePicture(imgID)
{
	url = document.getElementById(imgID).src;
	url_big = url.replace("_small", "_big");
	
	url_big = url_big.replace("http://", "");
	poz = url_big.indexOf("/");
	url_big = url_big.substr(poz+1);
        
    //alert(url_big);
	window.open("showPicture.aspx?img="+url_big, "", "scrollbars=0, menubars=0, toolbars=0, location=0, directories=0, status=0, width=10, height=10, top=300, left=300");
}




/*	Validation */
function ValidateContactForm()
{
	var region=document.ContactForm.region;
	var product=document.ContactForm.product;
	var company=document.ContactForm.company;
	var name=document.ContactForm.name;
	var email=document.ContactForm.email;
	var email2=document.ContactForm.email2;
	var textarea=document.ContactForm.textarea;
	
	if ((region.value==null)||(region.value==""))
	{
		alert("Please select the region");
		region.focus();
		return false;
	}
	
	if ((product.value==null)||(product.value==""))
	{
		alert("Please select the product");
		product.focus();
		return false;
	}
	
	if ((company.value==null)||(company.value==""))
	{
		alert("Please enter the company");
		company.focus();
		return false;
	}
	
	if ((name.value==null)||(name.value==""))
	{
		alert("Please enter you name");
		name.focus();
		return false;
	}
	
	if (echeck(email.value)==false)
	{
		email.focus();
		return false;
	}
	
	if ((email.value==null)||(email.value=="")){
		alert("Please Enter your Email");
		email.focus();
		return false;
	}
	
	if (email.value != email2.value)
	{
		alert("Please validate your email");
		email2.focus();
		return false;
	}
	
	if ((textarea.value==null)||(textarea.value==""))
	{
		alert("Please enter the comments");
		textarea.focus();
		return false;
	}

	return true;	
}

function ValidateRMAForm()
{
	var destination=document.RMAForm.destination;
	var delivery=document.RMAForm.delivery;
	var name=document.RMAForm.name;
	var company=document.RMAForm.company;
	var address=document.RMAForm.address;
	var city=document.RMAForm.city;
	var postal=document.RMAForm.postal;
	var country=document.RMAForm.country;
	var phone=document.RMAForm.phone;
	var fax=document.RMAForm.fax;
	var email=document.RMAForm.email;
	var email2=document.RMAForm.email2;
	
	if ((destination.value==null)||(destination.value==""))
	{
		alert("Please select the destination");
		destination.focus();
		return false;
	}
	
	if ((delivery.value==null)||(delivery.value==""))
	{
		alert("Please select the delivery");
		delivery.focus();
		return false;
	}
	
	if ((name.value==null)||(name.value==""))
	{
		alert("Please enter your name");
		name.focus();
		return false;
	}
	
	if ((company.value==null)||(company.value==""))
	{
		alert("Please enter the company");
		company.focus();
		return false;
	}
	
	if ((address.value==null)||(address.value==""))
	{
		alert("Please enter the address");
		address.focus();
		return false;
	}
	
	if ((city.value==null)||(city.value==""))
	{
		alert("Please enter the city");
		city.focus();
		return false;
	}
	
	if ((postal.value==null)||(postal.value==""))
	{
		alert("Please enter the postal");
		postal.focus();
		return false;
	}
	
	if ((country.value==null)||(country.value==""))
	{
		alert("Please enter the country");
		country.focus();
		return false;
	}
	
	if ((phone.value==null)||(phone.value==""))
	{
		alert("Please enter the phone");
		phone.focus();
		return false;
	}
	
	if ((fax.value==null)||(fax.value==""))
	{
		alert("Please enter the fax");
		fax.focus();
		return false;
	}
	
	if (echeck(email.value)==false)
	{
		email.focus();
		return false;
	}
	
	if ((email.value==null)||(email.value=="")){
		alert("Please Enter your Email");
		email.focus();
		return false;
	}
	
	if (email.value != email2.value)
	{
		alert("Please validate your email");
		email2.focus();
		return false;
	}

	return true;	
}


function ValidateDownloadsForms(frm)
{
    if(ValidateCheckboxes(frm)==false)
    {
        alert("Please select a document to download");
        return false;
    }
	if (frm.region != null)
	{	    
		var region=frm.region;
		var company=frm.company;
		var name=frm.name;
		var email=frm.email;
		var email2=frm.email2;
		
		if ((region.value==null)||(region.value==""))
		{
			alert("Please select the region");
			region.focus();
			return false;
		}
		
		if ((company.value==null)||(company.value==""))
		{
			alert("Please enter the company");
			company.focus();
			return false;
		}
		
		if ((name.value==null)||(name.value==""))
		{
			alert("Please enter you name");
			name.focus();
			return false;
		}
		
		if (echeck(email.value)==false)
		{
			email.focus();
			return false;
		}
		
		if ((email.value==null)||(email.value=="")){
			alert("Please Enter your Email");
			email.focus();
			return false;
		}
		
		if (email.value != email2.value)
		{
			alert("Please validate your email");
			email2.focus();
			return false;
		}
	}

	return true;	
}

function ValidateCheckboxes(frm)
{
    var chkCnt=0; 
    var checkboxs = frm.getElementsByTagName('input');
    for(var i = 0, inp; inp = checkboxs[i]; i++) {
        if(inp.type.toLowerCase() == 'checkbox') {
            if(inp.checked)
                chkCnt++;
        }
    }
    if(chkCnt == 0)
        return false;
    else 
        return true;    
}



function echeck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
}


