// KioskTerminals Functions
// Author: Serkanz
// File: Functions.js

function createTitle(){
	document.title = 'KioskTerminals.eu > '+document.title;
}
window.onload=createTitle;

//open a custom window function
function fixedSize(url,name,features) {
	window.open(url,name,features);
}

//search validation function
function search(){
  if(this.document.getElementById("searchbox_top").value != ""){
    location.href = "search9e4a.html?zoom_query="+this.document.getElementById("searchbox_top").value+"&zoom_per_page=10&zoom_and=0&zoom_sort=0";
  } else {
    alert("Please enter a search query.");
	this.document.getElementById("searchbox_top").focus();
  }
}

function searchProducts(){
  if(this.document.getElementById("product_search").value != ""){
    location.href = "search9e4a.html?zoom_query="+this.document.getElementById("product_search").value+"&zoom_per_page=10&zoom_and=0&zoom_sort=0";
  } else {
    alert("Please enter a search query.");
	this.document.getElementById("product_search").focus();
  }
}

//function to show/hide windows in browser
var last_display = '';
function showHide(e){
	if(last_display != e){
		this.document.getElementById(e).style.display = '';
		this.document.getElementById(last_display).style.display = 'none';
		last_display = e;
	}
}

//create menu function
function createMenu(){
	document.write('<ul id=\"links\" class=\"MenuBarHorizontal\"><li><a href=\"products.html\" title=\"Products\" class=\"MenuBarItemSubmenu\"><b>Products</b></a><ul><li><a href=\"standard_designs.html\" title=\"Standard Kiosks\">Standard Kiosks</a></li><li><a href=\"digital_signs.html\" title=\"Digital Signs\">Digital Signs</a></li><li><a href=\"schweickart.html\" title=\"J. Schweickart Collection\">J. Schweickart Collection</a></li><li><a href=\"custom_designs.html\" title=\"Custom Enclosures\">Custom Enclosures</a></li><li><a href=\"components.html\" title=\"Components\">Components</a></li><li><a href=\"construction.html\" title=\"Construction\">Construction</a></li></ul></li><li><a href=\"services.html\" title=\"Services\" class=\"MenuBarItemSubmenu\"><b>Services</b></a><ul><li><a href=\"design_services.html\" title=\"Design Services\">Design Services</a></li><li><a href=\"installation.html\" title=\"Installation\">Installation</a></li><li><a href=\"maintenance.html\" title=\"Maintenance\">Maintenance</a></li></ul></li><li><a href=\"company.html\" title=\"Company\" class=\"MenuBarItemSubmenu\"><b>Company</b></a><ul><li><a href=\"about_us.html\" title=\"About Us\">About Us</a></li><li><a href=\"ada.html\" title=\"ADA Compliancy\">ADA Compliancy</a></li><li><a href=\"faqs.html\" title=\"Frequently Asked Questions\">FAQs</a></li><li><a href=\"privacy.html\" title=\"Privacy Statement\">Privacy Statement</a></li><li><a href=\"warranty.html\" title=\"Warranty Information\">Warranty Information</a></li></ul></li><li><a href=\"quotation.php\" title=\"Get a Quotation\"><b>Get a Quotation</b></a></li><li><a href=\"contact.php\" title=\"Contact Us\"><b>Contact Us</b></a></li><li><a href=\"index.html\" title=\"Home\"><b>Home</b></a></li></ul>');
	var MenuBar1 = new Spry.Widget.MenuBar("links", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
}
//<li><a href=\"certifications.html\" title=\"Certifications\">Certifications</a></li>

//create footer function
function createFooter(){
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-left:10px;"><tr><td style="line-height:20px" class="body_text_white"><p><img src="images/flag_turkey.jpg" align="absmiddle" style="border: solid 1px #000000" title="Turkey"> +90-216-305-2903<img src="images/flag_uk.jpg" align="absmiddle" style="border: solid 1px #000000" title="AU"> +44 207 193 2740   <img src="images/flag_china.jpg" align="absmiddle" style="border: solid 1px #000000" title="China"> +86-135-015-70511| Fax: +61 2 9519 2094 | Email: <a href="mailto:sales@kioskterminals.eu " style="color:#ffff00">sales@kioskterminals.eu </a><br />Copyright &copy; 2009 KT Technology. All Rights Reserved. <a href="privacy.html" style="color:#ffff00">Privacy Statement</a> | <a href="warranty.html" style="color:#ffff00">Warranty Information</a></p></td></tr></table>');
}

//image swaps
function swapImage(image,href,title){
	document.model.src = image;
	document.getElementById('model_link').href = 'javascript:popImage(\''+href+'\', \''+title+'\');';
}
function swapType(id,content,type){
	if(type=='flash'){
		document.getElementById(id).innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"500\" height=\"500\"><param name=\"movie\" value=\"images/products/medium/"+content+"\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><embed src=\"images/products/medium/"+content+"\" width=\"500\" height=\"500\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed></object>";
	} else {
		content = content.split("|");
		document.getElementById(id).innerHTML = "<a href=\"javascript:popImage('images/products/xlarge/"+content[0]+"','"+content[1]+"');\" name=\"model_link\" id=\"model_link\"><img src=\"images/products/medium/"+content[0]+"\" name=\"model\" width=\"500\" height=\"500\" border=\"0\" id=\"model\" /></a>";
	}
}

//
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_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 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_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];}
}
//

//validation function
function validateForm(name){
  var theform = document.getElementById(name);
  if(!Spry.Widget.Form.validate(theform)){
    alert('Please go back and fix the fields that are highlighted red.');
    return false;
  } else {
    theform.submit();
  }
}

//reset function
function resetForm(name){
  var theform = document.getElementById(name);
  theform.reset();
}

//cookie functions
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	if(readCookie(name)!=''&&value!=''){
		if(readCookie(name).search(value.split(',')[1])==-1){
			document.cookie = name+"="+value+'|'+readCookie(name)+expires+"; path=/";
		}
	} else {
		document.cookie = name+"="+value+expires+"; path=/";
	}
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
	var r = readCookie('recent');
	if(r != ""){
		document.getElementById("recent_container").innerHTML = "<div class=\"body_text_black\" style=\"padding:5px; padding-top:0px;\"><i>Empty</i></div>";
	}
}

function recentlyViewed(){
	var r = readCookie('recent').split('|');
	var max_shown = 10;
	if(r != ""){
		document.write('<div id=\"recent_container\"><ul>');
		for(i=0;i<r.length;i++){
			rv = r[i].split(',');
			if(i<max_shown){
				document.write('<li class=\"list_elements\"><a href=\"'+rv[1]+'\">'+rv[0]+'</a></li>');
			}
		}
		document.write('</ul></div>');
	} else {
		document.write('<div id=\"recent_container\" class=\"body_text_black\" style=\"padding:5px; padding-top:0px;\"><i>Empty</i></div>');
	}
}

//Random Image
//generateImage("images/ph1.jpg,images/ph2.jpg,images/ph3.jpg,images/ph4.jpg,images/ph5.jpg");
function generateImage(images) {
	image_array = images.split(",");
	//randomizes images
	var n = Math.floor(Math.random() * image_array.length);
	document.write('<img src="'+image_array[n]+'"></a>');
}

//EU stat counter
function statCounter(){
	document.write('<!-- Start of StatCounter Code --><script type="text/javascript">var sc_project=4309267;var sc_invisible=1;var sc_partition=54;var sc_click_stat=1;var sc_security="21efbea1";</script><script type="text/javascript" src="../www.statcounter.com/counter/counter.js"></script><noscript><div class="statcounter"><a title="hit counter" href="http://www.statcounter.com/free_hit_counter.html" target="_blank"><img class="statcounter" src="http://c.statcounter.com/4309267/0/21efbea1/1/" alt="hit counter" /></a></div></noscript><!-- End of StatCounter Code -->');
}

//pop up code
// Set the horizontal and vertical position for the popup
PositionX = 0;
PositionY = 0;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 100;
defaultHeight = 100;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;
// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','test',optNN);}
if (isIE){imgWin=window.open('about:blank','test',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;');
writeln('var AutoClose='+AutoClose+';');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');
writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height)+32;');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
writeln('window.innerWidth=document.images["my_image"].width;');
writeln('window.innerHeight=document.images["my_image"].height+32;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('function doPrint(){bypass=true;this.window.print();}');
writeln('var bypass=false;');
writeln('function bypassClose(){if(AutoClose){if(bypass){bypass=false;}else{self.close();}}}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" style="background-color:#ffffff">')
else writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="bypassClose();" style="background-color:#ffffff">');
writeln('<div align="center"><a href="javascript:self.close();"><img name="my_image" src='+imageURL+' style="display:block" border="0" alt="Close Window"></a></div><div align="center" style="padding-top:5px"><a href="#" onMouseDown="doPrint();"><img src="images/button_print.jpg" border="0" alt="Print Image"></a>&nbsp;<a href="javascript:self.close();"><img src="images/button_closewindow.jpg" border="0" alt="Close Window"</a></div></body></html>');
close();
}}