// JavaScript Document
oldOffer=''


fromFlag = '';
function CreateHttpObject() {
var objXMLHttp=null
if(window.XMLHttpRequest){//case for ie7+ and opera,ff,chrome,safari
objXMLHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){//case ie5 and 6
objXMLHttp = ActiveXObject("Microsoft.XMLHTTP");
}
else{
alert("Your Browser Does Not Support XMLHTTP");
return null; //return null in case no browser support
}
return objXMLHttp
}


function postAjaxFile(urlPage,parameters) {
	xmlHttpPost=CreateHttpObject()
	if (xmlHttpPost==null) {
		alert ("Browser does not support HTTP Request")
		return
	} 
	xmlHttpPost.onreadystatechange=stateChangedPost
	xmlHttpPost.open("POST",urlPage,true);
	xmlHttpPost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
	//alert(parameters)
	xmlHttpPost.setRequestHeader("Content-length", parameters .length);   
	xmlHttpPost.setRequestHeader("Connection", "close"); 
	xmlHttpPost.send(parameters)

}


function showPic(src){
	document.getElementById('big_awards').style.backgroundImage='url('+src+')'
	showDiv('awards')
	
	}
function hidePic(divid){
hideDiv(divid)
	
	}
function stateChangedPost() { 
	if (xmlHttpPost.readyState==4 || xmlHttpPost.readyState=="complete") { 
		if (fromFlag == 1){
			//alert(xmlHttpPost.responseText)
			document.getElementById('error_message_contact_div').className =""
			document.getElementById('error_message_contact_div').innerHTML="Your email has been sent."
		}
	
	
	}
	
}
function selectOffer(object,picture,price, image){
	if (oldOffer.length == 0)
	{
		
		oldOffer = "special_0"
	
	}
	if (oldOffer != object){
		document.getElementById(object).className='special_offers selected';
		document.getElementById(oldOffer).className='special_offers';	
		oldOffer =object;
		changeBg(image, 'offer_link_id')
		updateImage('offer_image',picture);
		setLink('special_picture',document.getElementById(object+"_input").value)
		document.getElementById('offer_price').innerHTML = price;
	}
	
}
function changeBg(image,divId){
	document.getElementById(divId).style.backgroundImage='url('+image+')';
}
function showNews(divId,from,to){
	
	expandDiv(divId,from,to,2);
			
}
function showServices(){
	
	to =document.getElementById('service_sub_content_id').offsetHeight;
	document.getElementById('more_service_id').style.display="none";
	document.getElementById('seperator2_div').style.display="block";
	
	
	expandDiv('roger',0,to+30,1)
}

function  setLink(divId,linkValue){
	//alert(linkValue)
	document.getElementById(divId).onclick=function(){window.location =linkValue}
	//document.getElementById(divId).onclick=function(){alert(linkValue)}
}
function validateForm(){
	isValid = true;
	var paramLength = arguments.length;
	for ( i = 0 ; i < paramLength ;i++)
	{	parArray = arguments[i].split("@@")
		thislength = parArray.length;
		fieldName = parArray[0]
		
		if (thislength>1){			
			fieldType = parArray[1];
			if (fieldType == 'email'){
					isValideEmail = validateEmail(document.getElementById(fieldName).value)
					if (!isValideEmail){
						oldClass = document.getElementById(fieldName).parentNode.className
						document.getElementById(fieldName).parentNode.className = oldClass +" missing";
						isValid = false;
					//	alert(isValid)
						
					}else{
					oldClass = document.getElementById(fieldName).parentNode.className	;
						
					if (oldClass.split("email").length >1)
					{
						oldClass = "input_content email"
						
					}else
					{
						oldClass = "input_content"
					}
						
						document.getElementById(fieldName).parentNode.className = oldClass;	
						//isValid = true;
						
					}
					
				}else if(fieldType == "confirm"){
					isValidPassword = validPassword(document.getElementById(fieldName).value,document.getElementById(fieldName+"_confirm").value)
					if (!isValidPassword){
						oldClass = document.getElementById(fieldName).parentNode.className
						document.getElementById(fieldName).parentNode.className =oldClass +" missing";
						document.getElementById(fieldName+"_confirm").parentNode.className = oldClass +" missing";
						isValid = false;
						
					}else{
						
						document.getElementById(fieldName).parentNode.className = "input_content";
						document.getElementById(fieldName+"_confirm").parentNode.className = "input_content";
						//isValid = true;
						
					}
				}
		}else
		{
			
			if (document.getElementById(fieldName).value =='' ){
				//alert('d')
					oldClass = document.getElementById(fieldName).parentNode.className	;	
					document.getElementById(fieldName).parentNode.className = oldClass + " missing";
					
					isValid = false;
			}else{		
					oldClass = document.getElementById(fieldName).parentNode.className	;
					if (oldClass.split("email").length >1)
					{
						oldClass = "input_content email"
					
					}else if(oldClass.split("subject").length >1)
					{
						oldClass = "input_content subject"
					}else 
					{
						oldClass = "input_content"
					}
					
					document.getElementById(fieldName).parentNode.className = oldClass;	
						//isValid = true;
			}
		}
	}
	//alert(isValid)
	return isValid;
}
function validateEmail(email){
	var isValid = true
	var email = email
		AtPos = email.indexOf("@")
		StopPos = email.lastIndexOf(".")
	if (AtPos == -1 || StopPos == -1)
	{
		
		isValid = false ;
		//alert(isValid)
	}
	
	return isValid;
}
function sendContact()
{
	isValidText = true;
	isValuArea = true;
	
	isValidText =  validateForm('contact_subject','contact_name','contact_email@@email');
//		isValidText =true;
	
	
	 
	 if (isValidText){
		 	// document.getElementById('error_message_contact_div').innerHTML = "sending ";
			document.getElementById('error_message_contact_div').innerHTML = '';
		 	document.getElementById('error_message_contact_div').className = 'loader_contact';
		 	//contact_phone = document.getElementById('contact_phone').value;
			//alert('')
			
			contact_name = document.getElementById("contact_name").value;
			contact_email = document.getElementById("contact_email").value;
			contact_subject = document.getElementById("contact_subject").value;
			contact_message = document.getElementById("contact_message").value;
			mailto = getCheckedValue(document.forms['send_contant_form'].elements['emailTo'])
	
			fromFlag = 1; 
			// URL = "/Home/sendContact";
			URL = document.getElementById("Urlsend").value;
			//alert('s')
			//alert(URL)
			var poststr ="contact_name="+encodeURI(contact_name)+"&contact_email="+encodeURI(contact_email)+"&contact_subject="+encodeURI(contact_subject)+"&contact_message="+encodeURI(contact_message)+"&mailto="+encodeURI(mailto);;
	   // alert(poststr)
	    postAjaxFile(URL,poststr);

		 
	 }else{
			// document.getElementById('error_message_contact_div').innerHTML='check teh fields';
			// document.getElementById('error_message_contact_div').className='error_message_conract';
		 
		 }
}
function setPageType(){
	pageType = document.getElementById('pageType').value;
	return pageType;
	}
function sendNewsLetter()
{
	isValidText = true;
	isValuArea = true;
	
	isValidText =  validateForm('name','phone','email@@email','country');
//		isValidText =true;
	
	
	 
	 if (isValidText){
		 	// document.getElementById('error_message_contact_div').innerHTML = "sending ";
		 	document.getElementById('error_message_contact_div').className = 'loader_contact';
		 	//contact_phone = document.getElementById('contact_phone').value;
			//alert('')
			name = document.getElementById("name").value;
			phone = document.getElementById("phone").value;
			position = document.getElementById("position").value;
			company = document.getElementById("company").value;
			email = document.getElementById("email").value;
			country = document.getElementById("country").value;
		
			
	
			fromFlag = 1; 
			
			URL = document.getElementById("Urlsend").value;
			// URL = "/Home/addNewsLetter";
			var poststr ="name="+encodeURI(name)+"&phone="+encodeURI(phone)+"&position="+encodeURI(position)+"&company="+encodeURI(company)+"&email="+encodeURI(email)+"&country="+encodeURI(country);
	   // alert(poststr)
	    postAjaxFile(URL,poststr);

		 
	 }else{
			// document.getElementById('error_message_contact_div').innerHTML='check teh fields';
			// document.getElementById('error_message_contact_div').className='error_message_conract';
		 
		 }
}
function updateImage(imageId,src){
	//alert(src)
	document.getElementById(imageId).src =src;
}
function showAllProducts(toHeight){
	expandDiv('middle_content_hidden',500,toHeight)
	
	
}
function setHeight(height,width)
{
	window.document["menu_flash_id"].setAttribute("height",height)
	window.document["menu_flash_id"].setAttribute("width",width)
}

function  getRoot()
{	urlRoot = document.getElementById('urlRoot').value
	return urlRoot;
//	window.document[flashId].SetVariable("urlRoot",urlRoot)
	
	//window.document["menu_flash_id"].setAttribute("width",width)
}


isOver = 0
function hidePup(divId){
	isOver = 0 
	//document.getElementById(divId).style.display='none';
	//document.getElementById("isOver").value=isOver
	//setTimeout(function (){hideDiv1(divId);document.getElementById(divId).style.display='none';},1000)
	//if(isOver == 0){
//	
//	document.getElementById(divId).style.display='none';
//	}
}

function showPup(divId){
	isOver = 1 
	//document.getElementById("isOver").value=isOver
	//document.getElementById(divId).style.display='block'
//	setTimeout("",1000)
//	if(isOver ==1){
	

	//	setTimeout(function (){document.getElementById(divId).style.display='block';showDiv1(divId);},1000)
//	}
	
}




oldDetailDIv = ""
function showDetails(div){
	if (oldDetailDIv.length ==0){
		oldDetailDIv= "overview_div";
		if (!document.getElementById("overview_div")){
			oldDetailDIv = "spec_id_0"
		}
	}
	
	if (oldDetailDIv !=div )
	{
//alert(div+"_menu")
		//alert(oldDetailDIv)
		document.getElementById(div+"_menu").className = "selected"
		document.getElementById(oldDetailDIv+"_menu").className = ""
		hideDiv(oldDetailDIv,div);
		
		//alert("roger")
		oldDetailDIv=div
	}
	
	
}
function showHome(div){
	if (oldDetailDIv.length ==0){
		oldDetailDIv= "welcome_1";
	}
	if (oldDetailDIv !=div )
	{
		document.getElementById(div+"_menu").className = "selected"
		document.getElementById(oldDetailDIv+"_menu").className = ""
		hideDiv(oldDetailDIv,div);
		
		
		oldDetailDIv=div
	}
	
	
}

function expandDiv(divid,from,to,flag){
	//alert(divid)
	var exampleFx = new Fx.Morph(divid, {
						duration: 2000,
						onComplete: function(){
                //and here we apply the highlight effect on complete
	        										//alert('df')
										isSlid=false;
										isopen = true;
										if(flag == 2){
											
											document.getElementById('view_all_id').style.display="none";
											}
										if (flag !=1){
										document.getElementById('more_products').style.display ='none';
										
										}else{
											
											}
									}

					});
				//if (!isSlid & !isopen){
					isSlid=true;
					//alert(parseInt(getScreenSizX()-440)/2)
					exampleFx.start({
						//'opacity':[0,1],
						//'width':[0,600],
						
						//'width':[width,width],
						//'height':[width,height],
						//'top':[top,top-parseInt(height/2)],
						'height':[from,to]
						
						//'display:'block
						
						
					});	

			//	}
}
function showDiv(divid){
	document.getElementById(divid).style.display ='block';
	var exampleFx = new Fx.Morph(divid, {
						duration: 500,
						onComplete: function(){
                //and here we apply the highlight effect on complete
	        										//alert('df')
										isSlid=false;
										isopen = true;
										//document.getElementById('more_products').style.display ='none';
									}

					});
				//if (!isSlid & !isopen){
					isSlid=true;
					//alert(parseInt(getScreenSizX()-440)/2)
					exampleFx.start({
						//'opacity':[0,1],
						//'width':[0,600],
						
						//'width':[width,width],
						//'height':[width,height],
						//'top':[top,top-parseInt(height/2)],
						'opacity':[0,1]
						
						//'display:'block
						
						
					});	

			//	}
}
function showDiv1(divid){
	if(isOver == 1){
	var exampleFx = new Fx.Morph(divid, {
						duration: 1000,
						onComplete: function(){
                //and here we apply the highlight effect on complete
	        										//alert('df')
										isSlid=false;
										isopen = true;
										//document.getElementById('more_products').style.display ='none';
									}

					});
				//if (!isSlid & !isopen){
					isSlid=true;
					//alert(parseInt(getScreenSizX()-440)/2)
					exampleFx.start({
						//'opacity':[0,1],
						//'width':[0,600],
						
						//'width':[width,width],
						//'height':[width,height],
						//'top':[top,top-parseInt(height/2)],
						'opacity':[0,1]
						
						//'display:'block
						
						
					});	
				}
					else{
					return false;	
						}

			//	}
}
function hideDiv(divid,dividtoShow){
	//alert(divid+","+dividtoShow)
	var exampleFx = new Fx.Morph(divid, {
						duration: 500,
						onComplete: function(){
                //and here we apply the highlight effect on complete
	        										//alert('df')
										isSlid=false;
										isopen = true;
										document.getElementById(divid).style.display ='none';
										showDiv(dividtoShow);
									}

					});
				//if (!isSlid & !isopen){
					isSlid=true;
					//alert(parseInt(getScreenSizX()-440)/2)
					exampleFx.start({
						//'opacity':[0,1],
						//'width':[0,600],
						
						//'width':[width,width],
						//'height':[width,height],
						//'top':[top,top-parseInt(height/2)],
						'opacity':[1,0]
						
						//'display:'block
						
						
					});	

			//	}
}
function hideDiv1(divid,dividtoShow){
	//alert(divid)
	if(isOver == 0){
	var exampleFx = new Fx.Morph(divid, {
						duration: 1000,
						onComplete: function(){
                //and here we apply the highlight effect on complete
	        										//alert('df')
										isSlid=false;
										isopen = true;
										
									}

					});
				//if (!isSlid & !isopen){
					isSlid=true;
					//alert(parseInt(getScreenSizX()-440)/2)
					exampleFx.start({
						//'opacity':[0,1],
						//'width':[0,600],
						
						//'width':[width,width],
						//'height':[width,height],
						//'top':[top,top-parseInt(height/2)],
						'opacity':[1,0]
						
						//'display:'block
						
						
					});	
				}else{
					return false;	
				}

			//	}
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
		//alert(radioLength)
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
			
		}
	}
	return "";
}
