//
//
x = 10; //((screen.width)/2 -285);
y = ((screen.height)/2 -225);
function setVisible(obj)
{
	obj = document.getElementById(obj);
	obj.style.position = "absolute";
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}

	function send(link){
	var page_location = location.href;
	page_location = page_location.replace("#category_desc", "");
	var details=(page_location+link);
	document.location.href=details;
}


function contact_us(){
	document.frm_print_email.action = "http://www.surfsideelectronics.com/index.php?main_page=contact_us";
	//document.frm_print_email.action = "http://entell4/surfsideelectronics/store_new/index.php?main_page=contact_us";
	document.frm_print_email.email_url.value = self.location;
	document.frm_print_email.submit();
}

function customized_orders(){
	document.frm_print_email.action = "http://www.surfsideelectronics.com/index.php?main_page=contact_us&customized=1";
	//document.frm_print_email.action = "http://entell4/surfsideelectronics/store_new/index.php?main_page=contact_us&customized=1";
	document.frm_print_email.email_url.value = self.location;
	document.frm_print_email.submit();
}

function email_this_page(){
	document.frm_print_email.action = "http://www.s354821688.onlinehome.us/index.php?main_page=email_this_page";
	//document.frm_print_email.action = "http://entell4/surfsideelectronics/store_new/index.php?main_page=email_this_page";
	document.frm_print_email.email_url.value = self.location;
	document.frm_print_email.email_title.value = document.title;
	document.frm_print_email.submit();
}

function show_filter(){
	document.getElementById('filter_products').style.display = 'inline';
}


	function tracking_source(){
		var refered_by=0;
		var query = location.search.substring(1);
		var pairs = query.split("&");
		for(var i = 0; i < pairs.length; i++) {
			var pos = pairs[i].indexOf('=');
			if (pos == -1) continue;
			var argname = pairs[i].substring(0,pos);
			if(argname=="source"){
				refered_by =1;
				var value = pairs[i].substring(pos+1);
			}
		} 
		
		if(refered_by ==1){
			var days = 30;
			var name = "referedby";
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
			document.cookie = name+"="+value+expires+"; path=/";	
		}
	}

	function login_logout()
	{
		tracking_source();

		var cookiestring=""+document.cookie;
		var index1=cookiestring.indexOf("custloggedin");
		if (index1==-1)
		 {
			document.write('Welcome! <a href ="index.php?main_page=login" class="greylightsmall" title ="Login">Sign In</a> or <a href="index.php?main_page=create_account" class="greylightsmall" title ="Register with Surfside Electronics, its easy.">Register</a> at Surfside Electronics');
		 }
		 else
		 {
			var index2=cookiestring.indexOf("cust_id");
			if(index2==-1)
			 {
					var customer_id ='0';
			 }
			 else
			 {
					var index3 = cookiestring.indexOf(';' , index2);
					if(index3==-1) index3 = cookiestring.length;
					var customer_id = cookiestring.substring(index2+7+1, index3);
					
			 }
			if(customer_id >1){
				var index2=cookiestring.indexOf("cust_name");
				if(index2==-1)
				 {
						var customer_name ='';
				 }
				 else
				 {
						var index3 = cookiestring.indexOf(';' , index2);
						if(index3==-1) index3 = cookiestring.length;
						var customer_name = cookiestring.substring(index2+9+1, index3);
						
				 }
				if(customer_name!=''){
					document.write('<b>Welcome '+customer_name+'  </b>&nbsp;&nbsp; <a href="index.php?main_page=account" class="greylightsmall">My Account</a> &nbsp;&nbsp; <a href="index.php?main_page=logoff" class="greylightsmall">Logout</a>&nbsp;');
				}
			}
			else{
				document.write('Welcome! <a href ="index.php?main_page=login" class="greylightsmall" title ="Login">Sign In</a> or <a href="index.php?main_page=create_account" class="greylightsmall" title ="Register with Surfside Electronics, its easy.">Register</a> at Surfside Electronics');
			 }
		 }

	}


	function print_invoice(url)
	{
		window.open(url,"print_inv", "width=800, height=600,toolbar=0, left=0,top=0, menubar=yes, scrollbars=yes, resizable=yes");
	}


	function Trim(TRIM_VALUE)
	{
		if(TRIM_VALUE.length < 1)
		{
			return"";
		}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE=="")
		{
			return "";
		}
		else
		{
			return TRIM_VALUE;
		}
	}

	//////////////////

	function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0)
		{
			return"";
		}
		var iTemp = v_length -1;
		while(iTemp > -1)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
		}
		return strTemp;
	}

	//////////////////

	function LTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		if(v_length < 1)
		{
			return"";
		}
		var v_length = VALUE.length;
		var strTemp = "";
		var iTemp = 0;
		while(iTemp < v_length)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
				///
			}
			else
			{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}
		return strTemp;
	}
	  
	//////////////////

	function check_email(emailaddress)
	{
		var emailStr = emailaddress;
		var checkTLD=1;
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

		var validChars="\[^\\s" + specialChars + "\]";

		var quotedUser="(\"[^\"]*\")";

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';

		var word="(" + atom + "|" + quotedUser + ")";

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

		var matchArray=emailStr.match(emailPat);

		if (matchArray==null) 
		{
			alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
			
		var user=matchArray[1];
		var domain=matchArray[2];

		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("The username contains invalid characters.");
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("The domain name contains invalid characters.");
		return false;
		   }
		}

		if (user.match(userPat)==null) {

		alert("The email doesn't seem to be valid.");
		return false;
		}

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {

		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Destination IP address is invalid!");
		return false;
		   }
		}
		return;
		}
				 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("The domain name does not seem to be valid.");
		return false;
		   }
		}

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
		}

		if (len<2) {
		alert("This address is missing a hostname!");
		return false;
		}
		return true;
	}  
//////////////////////////////

	function setemail()
	{
		if(document.frmsubscribe.email.value=="Enter your email address")
		{
			document.frmsubscribe.email.value="";
			document.frmsubscribe.email.className='signup_box_focus';
		}
	}

	function getemail()
	{
		if(document.frmsubscribe.email.value=="Enter your email address" || Trim(document.frmsubscribe.email.value)=="")
		{
			document.frmsubscribe.email.value="Enter your email address";
			document.frmsubscribe.email.className='signup_box_normal';
		}
	}

	function subscribe()
	{
		if(Trim(document.frmsubscribe.email.value)=="")
		{
			alert("Please enter your email address to receive best deals");
			document.frmsubscribe.email.focus();
		}
		else if(check_email(Trim(document.frmsubscribe.email.value))==true)
		{
			document.frmsubscribe.submit();
		}
		else{
			document.frmsubscribe.email.focus();
		}
	}

function entsub(event,ourform) {
  if (event && event.which == 13){
     subscribe();
  }
  else{
    return true;
  }
}
	///////////////

	//////////Menu AJAX	bof
    function Call_Ajax(php_url, qry_string, div_name) {
        var httpRequest;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

			//var queryString = "?products_id=" + prodid;
			httpRequest.onreadystatechange = function() { alertContents(httpRequest , div_name); };
			httpRequest.open('GET', php_url + qry_string, true);
			httpRequest.send('');

    }

    function alertContents(httpRequest, div_name) {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {

				//alert(httpRequest.responseText);

				document.getElementById(div_name).innerHTML = httpRequest.responseText;
				
            } else {
                //alert('There was a problem with the request.');
            }
        }

    }
	//////AJAX EOF

function sortpage()
{

	var curr_url = location.href;
	curr_url = curr_url.replace("#category_desc", "");

	var cut_url ='';
	var cut_url1 ='';
	var stpos = curr_url.indexOf("-o-");
	var stpos1 = curr_url.indexOf("-l-");
	if(stpos>0){
		var cut_url = curr_url.substr(0, stpos);
	}
	if(stpos1>0){
		cut_url1 = curr_url.substr(stpos1, curr_url.length);
	}

	if(cut_url!='' && cut_url1!=''){
		window.location.href = cut_url+'-o-'+document.filter.disp_order.value+cut_url1;
	}
	else{
		var stpos = curr_url.indexOf("-c-");
		var cut_url = curr_url.substr(0, stpos);
		var cut_url1 = curr_url.substr(stpos, curr_url.length);
		window.location.href = cut_url+'-o-'+document.filter.disp_order.value+'-l-1'+cut_url1;
	}

}

function check_contact(){
	if(Trim(document.contact_us.contactname.value)=="")
	{
		alert("Please enter your name.");
		document.contact_us.contactname.focus();
		return;
	}
	else if(Trim(document.contact_us.contactemail.value)=="")
	{
		alert("Please enter your email address.");
		document.contact_us.contactemail.focus();
		return;
	}
	else if(check_email(Trim(document.contact_us.contactemail.value)))
	{
		if(document.contact_us.subject.value=="Select Subject"){
			alert("please select subject.");
			document.contact_us.subject.focus();
			return;
		}
		else if(Trim(document.contact_us.enquiry.value)==""){
			alert("please enter your message.");
			document.contact_us.enquiry.focus();
			return;
		}
		else
		{
			document.contact_us.submit();
		}
	}
}


function show_estimator(){
	document.getElementById('shipping_estimator').style.display = 'inline';
}

function hide_estimator(){
	
	document.getElementById('shipping_estimator').style.display = 'none';
}

Checked_image='images_system/checked.jpg';
Unchecked_image='images_system/unchecked.jpg';
check_status=0;
function ShowCheck(img){
	if(check_status==0){
		img.src=Checked_image;
		check_status=1;
		document.quick_find_header.search_in_result.value=1;
	}
	else
	{
		img.src=Unchecked_image;
		check_status=0;
		document.quick_find_header.search_in_result.value=0;
	}
}

function hide_left(id){
	document.getElementById('div_c_'+id).style.display = 'inline';
	document.getElementById('div_e_'+id).style.display = 'none';
	document.getElementById('div_list_'+id).style.display = 'none';
}

function show_left(id){
	document.getElementById('div_c_'+id).style.display = 'none';
	document.getElementById('div_e_'+id).style.display = 'inline';
	document.getElementById('div_list_'+id).style.display = 'inline';
}


/////////Recently Viewed BOF
function recently_viewed(proid)
{
	var recentcookie=""+document.cookie;
	var index_pos=recentcookie.indexOf("recently_viewed");
	var add_prod =1;
	if(index_pos==-1)
	 {
			var recent_products ='';
			add_prod =1;
			//SetCookie("recently_viewed", proid);
			createCookie("recently_viewed", proid,"365")
	 }
	 else
	 {
			var index_pos1 = recentcookie.indexOf(';' , index_pos);
			if(index_pos1==-1) index_pos1 = recentcookie.length;
			var recent_products = recentcookie.substring(index_pos+15+1, index_pos1);
			recent_products = recent_products+","+proid;

			//SetCookie("recently_viewed", recent_products);
			createCookie("recently_viewed", recent_products,"365")
	 }
}

function SetCookie(cookiename, cookievalue) {
  //alert(cookiename+' >>'+ cookievalue);
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;

 document.cookie = cookiename + "=" + cookievalue+";path=/";
  return;
}

///////////////////////

function check_recently_viewed(){
	var recentcookie=""+document.cookie;
	var index_pos=recentcookie.indexOf("recently_viewed");
	if(index_pos!=-1){
			var index_pos1 = recentcookie.indexOf(';' , index_pos);
			if(index_pos1==-1) index_pos1 = recentcookie.length;
			var recent_products = recentcookie.substring(index_pos+15+1, index_pos1);
			//var no_products = recent_products.indexOf(',');
			//alert(recent_products);
			if(recent_products !=''){
				document.getElementById('show_recent').style.display = 'inline';
			}
			else{
				document.getElementById('show_recent').style.display = 'none';
			}
	}
	else{
		document.getElementById('show_recent').style.display = 'none';
	}
}

//////////Recently Viewed AJAX	BOF
    function show_recently_viewed(ignore_products) {
        var httpRequest;
		if (typeof ignore_products == "undefined") {
			 ignore_products = "0";
		}		
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

		var recentcookie=""+document.cookie;
		var index_pos=recentcookie.indexOf("recently_viewed");
		var add_prod =1;
		if(index_pos!=-1)
		{
				var index_pos1 = recentcookie.indexOf(';' , index_pos);
				if(index_pos1==-1) index_pos1 = recentcookie.length;
				var recent_products = recentcookie.substring(index_pos+15+1, index_pos1);
				var queryString = "?recent_ids=" + recent_products+"&ignore_products="+ignore_products;
				httpRequest.onreadystatechange = function() { alertContents1(httpRequest); };
				httpRequest.open('GET', "recent_products_listing.php" + queryString, true);
				httpRequest.send('');
		}
    }

    function alertContents1(httpRequest) {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                document.getElementById('recently').innerHTML = httpRequest.responseText;
            } else {
                //alert('There was a problem with the request.');
            }
        }
    }
//////Recently Viewed AJAX EOF

/////////Recently Viewed EOF

function show_subject(){
	//alert(document.contact_us.subject.selectedIndex);
	if(document.contact_us.subject.selectedIndex =="4"){
		document.getElementById('div_subject').style.display = 'inline';
	}
	else{
		document.getElementById('div_subject').style.display = 'none';
	}
}

///////////

function print_this_page()
{
	document.frm_print_email.action = 'index.php?main_page=product_info&products_id='+document.frm_print_email.email_products_id.value+'&cPath=139&print_window=1';
	document.frm_print_email.target ="printWin";
	window.open("","printWin", "width=790, height=500,toolbar=0, left=0,top=0, menubar=yes, scrollbars=yes, resizable=yes"); 
	var a = window.setTimeout("document.frm_print_email.submit();",500); 
}



//////////AJAX Info	BOF
    function Ajax_info(file_name, screen_size) {
        var httpRequest;
		if (typeof ignore_products == "undefined") {
			 ignore_products = "0";
		}		
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		
		var resoW = screen.width;
		var resoH = screen.height;
		var caller_url='';
		if(file_name.indexOf("?")>0){
			caller_url = file_name+'&h='+resoH+'&w='+resoW;
		}
		else{
			caller_url = file_name+'?h='+resoH+'&w='+resoW;
		}
		httpRequest.onreadystatechange = function() { shipping_contents(httpRequest, screen_size); };
		httpRequest.open('GET', caller_url, true);
		httpRequest.send('');
    }

    function shipping_contents(httpRequest, screen_size) {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                document.getElementById('contents').innerHTML = httpRequest.responseText;
				visible_content(screen_size);
            } else {
                document.getElementById('contents').innerHTML = 'There was a problem with the request.';
				visible_content(screen_size);
            }
        }
    }
//////AJAX Info EOF

function search_go(){
	if(Trim(document.quick_find_header.keywords.value)=="Enter Search Keywords" || Trim(document.quick_find_header.keywords.value)=="")
	{
		alert("please enter your search keywords");
		return;
	}
	else{
		document.quick_find_header.submit();
	}
}

function search_click(){
	//hide all category & all brands menu BOF
	/*
	var menu=anylinkcssmenu.menusmap['anchorclass4'];
	anylinkcssmenu.hidemenu( menu.id);
	var menu=anylinkcssmenu.menusmap['anchorclass5'];
	anylinkcssmenu.hidemenu( menu.id);
	var menu=anylinkcssmenu.menusmap['anchorclass6'];
	anylinkcssmenu.hidemenu( menu.id);
	var menu=anylinkcssmenu.menusmap['anchorclass7'];
	anylinkcssmenu.hidemenu( menu.id);
	var menu=anylinkcssmenu.menusmap['anchorclass8'];
	anylinkcssmenu.hidemenu(menu.id);
	*/
	//hide all category & all brands menu EOF
}

function search_focus(objElement){
	if(objElement.value=="Enter Search Keywords"){
		objElement.value ='';
		objElement.className='search_text_box_normal';
	}
	else{
		objElement.className='search_text_box_focus';
	}
}

function search_blur(objElement){
	if(Trim(objElement.value)==""){
		objElement.value="Enter Search Keywords";
	}

	if(Trim(objElement.value)=="Enter Search Keywords"){
		objElement.className='search_text_box_normal';
	}
	else{
		objElement.className='search_text_box_focus';
	}
}

function search_key(objElement){
	objElement.className='search_text_box_focus';
}

function text_focus(objElement){
	objElement.className='text_box_focus';
}

function text_blur(objElement){
	objElement.className='text_box_blur';
}

function toggleColor(objElement){
	/*
	if (objElement.className=='search_text_box_normal'){
		objElement.className='search_text_box_focus';
	}else{
		objElement.className='search_text_box_normal';
	}
	*/
}

function couponpopupWindow(url)
{
   window.open(url,"printWin", "width=770, height=500,toolbar=0, left=0,top=0, menubar=no, scrollbars=yes, resizable=yes"); 
}

function print_page()
{
	var page_location = location.href;
	page_location = page_location.replace("#product_details", "");
	page_location = page_location.replace("#brand_details", "");
	page_location = page_location.replace("#buy", "");
	page_location = page_location.replace("#more_views", "");
	page_location = page_location.replace("#read_reviews", "");

	page_location = page_location+"&print_window=1";
	//alert(page_location )
   window.open(page_location,"printpage", "width=770, height=500,toolbar=0, left=0,top=0, menubar=no, scrollbars=yes, resizable=yes"); 
}

function CreateBookmarkLink() 
{
	var page_location = location.href;
	page_location = page_location.replace("#product_details", "");
	page_location = page_location.replace("#brand_details", "");
	page_location = page_location.replace("#buy", "");
	page_location = page_location.replace("#more_views", "");
	page_location = page_location.replace("#read_reviews", "");

	var page_title = document.title;

	if (window.sidebar) 
	{ 
		window.sidebar.addPanel(page_title, page_location,"");	
	} 
	else if( window.external ) 
	{ 
		window.external.AddFavorite( page_location, page_title); 
	}	
	else if(window.opera && window.print) 
	{ 
		return true; 
	} 
} 



function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function hide_popup(){
	document.getElementById('overlay').style.display = 'none';
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function show_cool_popup(file_name, screen_size){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
	}
	var objDetails = document.getElementById('details');
	objDetails.style.visibility = 'hidden';
	

	var objOverlay = document.getElementById('overlay');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.zIndex = '99998';
	if(arrayPageSize[2]<= 999){
		objOverlay.style.width = '1000px';
	}
	else{
		if (self.innerHeight) { //others than explorer
			objOverlay.style.width = '100%';
		}
		else{
			objOverlay.style.width = arrayPageSize[2] + 'px';
		}
	}
	objOverlay.style.top = 0;
	objOverlay.style.left = 0;
	objOverlay.style.position = 'absolute';
	objOverlay.style.display = 'block';
	objOverlay.style.visibility = 'visible';
	
	var objLoadingImage = document.getElementById('loadingImage');
	objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
	objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
	objLoadingImage.style.zIndex = '99999';
	objLoadingImage.style.position = 'absolute';
	objLoadingImage.style.visibility = 'visible';
	objLoadingImage.style.display = 'block';

	Ajax_info(file_name, screen_size);
}

function visible_content(screen_size){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objLoadingImage = document.getElementById('loadingImage');
	objLoadingImage.style.visibility = 'hidden';

	var objDetails = document.getElementById('details');
	objDetails.style.zIndex = '100000';

	

	objDetails.style.top = (arrayPageScroll[1] +10)+'px';

	if(screen_size==1){
		if(screen.width<= 999){
			if (self.innerHeight) {	// all except Explorer
				objDetails.style.height = (arrayPageSize[3]-38)+'px';
			}
			else{
				objDetails.style.height = (arrayPageSize[3]-25)+'px';
			}
		}
		else{
			if (self.innerHeight) {	// all except Explorer
				objDetails.style.height = (arrayPageSize[3]-22)+'px';
			}
			else{
				objDetails.style.height = (arrayPageSize[3]-8)+'px';
			}
		}
	}

	if(arrayPageSize[2]<= 999){
		objDetails.style.width = '1000px';
	}
	else{
		if (self.innerHeight) { //others than explorer
			objDetails.style.width = '100%';
		}
		else{
			objDetails.style.width = arrayPageSize[2] + 'px';
		}
	}
	
	if(screen_size==3){//for color popup
		var cool_table = document.getElementById('cool_table');
		cool_table.style.width="320px";
	}
	else{
		var cool_table = document.getElementById('cool_table');
		cool_table.style.width="979px";
	}

	objDetails.style.left = '0px';

	objDetails.style.display = 'block';
	objDetails.style.visibility = 'visible';

}

function show_alt_images(show_div)
{
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
		var div_name =x[i].id;
		
		if(div_name.substr(0,7)  == "pop_img")
		{
			if (x[i].id == show_div)
			{
				x[i].style.display = 'inline';
			}
			else
			{
				x[i].style.display = 'none';
			}
		}
	}
}



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 = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function setDefaultColor(name,value,days){
	createCookie(name,value,days);
	hide_popup();
	window.location=window.location;
}

function send_to_url(url){
	window.location.href =url;
}

function limitText(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		document.getElementById('countdown').innerHTML = limitNum - limitField.value.length;
	}
}

function search_ideas(){
	if(Trim(document.frm_design_idea.design_keys.value)==''){
		alert("Please enter your search keywords.");
		document.frm_design_idea.design_keys.focus();
	}
	else{
		document.frm_design_idea.submit();
	}
}

function new_captcha()
{
	var c_currentTime = new Date();
	var c_miliseconds = c_currentTime.getTime();
	document.getElementById('captcha').src = 'vcode.php?x='+ c_miliseconds;
}
