function popup(URL)
{
	document.pop = window.open(URL,"popup","toolbar=no,status=no,scrollbars=no,resizable=no,dependent=yes,left=20,top=20,height=10,width=10");
	document.pop.focus();
	return false;
}

function closeWin()
{
	setTimeout("window.close()", 5000);
}
function showHideElement(id){
	var obj = findObj(id);
	if(obj.style.visibility=="hidden")
		obj.style.visibility="visible";
	else
		obj.style.visibility="hidden";
}
var g_translate = new Array();

var g_message = new Array()
var i_substring = 0;
var i_presubstring = 0;
var i_message = 0;
var messagecontent = "";
var messagepresubstring = "";
var messageaftersubstring = "";

function showticker()
{
	if (i_substring <= g_message[i_message][0].length - 1)
	{
		i_presubstring = i_substring;
		i_substring++;
		
		messagepresubstring = g_message[i_message][0].substring(0,i_presubstring);
		messageaftersubstring = g_message[i_message][0].substring(i_presubstring,i_substring);
		messagecontent = messagepresubstring;
		messagecontent += "<b>" + messageaftersubstring + "</b>";
		document.objinfo.innerHTML = "<a href=\"" + g_message[i_message][1] + "\" class=\"pagelink\" style=\"position: relative; display: block;\">" + messagecontent + "</a>";
		var timer = setTimeout("showticker()", 80);
	}
	else
	{
		clearTimeout(tickertimer);
		var tickertimer = setTimeout("changemessage()", 2000);
	}
}

function changemessage()
{
	i_substring = 0;
	i_presubstring = 0;
	i_message++;
	if (i_message > g_message.length - 1)
		i_message = 0;

	showticker();
}

var menutimer = null;
function showmenu(over, menutype)
{
	var obj, menu, menuname;
	
	if (over.id)
		menuname = over.id
	else
		menuname = over.name + "menu"
	
	if (!(obj = findObj(menuname)))
		return;
	
	menu = (document.layers) ? obj : obj.style;

	if (menutimer)
		clearTimeout(menutimer);

	if (!over.id)
	{
		hidemenu(false);
		if (menutype == "right")
		{
			menu.left = (over.offsetLeft + over.scrollWidth - 4) + "px";
			menu.top = (over.offsetTop - 4) + "px";
		}
		else
		{
			menu.left = over.offsetLeft + "px";
			menu.top = (over.offsetTop + over.scrollHeight) + "px";
			/*if (obj.scrollWidth < over.scrollWidth)
			{
				if ((obj = findObj(over.name + "menutable")))
					(document.layers) ? obj.width = over.scrollWidth: obj.style.width = over.scrollWidth;
			}*/
		}
		
		document.menu = menu;
	}
	
	menu.visibility = "visible";
}

function hidemenu(wait)
{
	if (!document.menu)
		return;
	
	if (wait)
	{
		clearTimeout(menutimer);
		menutimer = setTimeout("document.menu.visibility = \"hidden\";", 500);
	}
	else
		document.menu.visibility = "hidden";
}

function findObj(n, d)
{
	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 = findObj(n,d.layers[i].document);

	if(!x && d.getElementById)
		x = d.getElementById(n);

	return x;
}

function changestyle(obj, clsname)
{
	//var cls = obj.className.split('_');
	obj.className = clsname
}

function CheckOption(obj)
{
	if(obj)
		obj.type == 'checkbox' ? obj.checked = !obj.checked : obj.checked = true;
}

function getCheckOption(obj)
{
		var index;
		for(index = 0; index < obj.length; index++)
			if(obj[index].checked)
				return obj[index].value;
}

function getPosition(element)
{
	var elem = element, x = 0, y = 0;
	while ((elem != null) && (typeof(elem) == 'object') && (typeof(elem.tagName) != 'undefined'))
	{
		y += elem.offsetTop;
		x += elem.offsetLeft;
		
		if (elem.tagName.toUpperCase() == 'BODY')
			break;

		elem = elem.offsetParent;
	}
	
	position=new Object();
	position.x=x;
	position.y=y;
	return position;
}

function tooltip(tid, tmessage, tx, ty, tvisibility)
{
	var objtooltip = findObj(tid);
	if(!objtooltip)
		return;
	
	objtooltip.innerHTML = unescape(tmessage);
	tooltipstyle = ((document.layers) ? objtooltip : objtooltip.style);
	tooltipstyle.left = tx;
	tooltipstyle.top = ty;
	tooltipstyle.visibility = tvisibility ? 'visible' : 'hidden';
}

function numbersonly(e)
{
	var key;

	if(window.event)
		key = e.keyCode;
	else if(e.which)
		key = e.which;
	else
		return true;
	
	return (key > 47 && key < 58);
}

function translate()
{
	//alert(document.location.href.indexOf("/en/"));
	var out;
	if(document.location.href.indexOf("/en/")>-1){
		out = arguments[0];
	}
	else
		out = g_translate[arguments[0]];
	
	if (!out)
		out = arguments[0];
	var cnt;
	for(cnt = 1; cnt < arguments.length; cnt++)
		out = out.replace(String('%' + cnt), arguments[cnt]);
	return out;
}

function DebugPrint(out)
{
	var objdebug = findObj("debug");
	objdebug.innerHTML += out + "<br>";
}

function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

//Form Validation//
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");
	   document.orderForm.txt_email.focus();
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	   alert("Invalid E-mail address");
	   document.orderForm.txt_email.focus();
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail address");
	    document.orderForm.txt_email.focus();
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail address");
	    document.orderForm.txt_email.focus();
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	   alert("Invalid E-mail address");
	   document.orderForm.txt_email.focus();
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail address");
	    document.orderForm.txt_email.focus();
	    return false
	 }

 return true;	 					
}



function Validation()
    {
      with(document.orderForm)
        {
           	if(txt_company.value.length ==0)
            {            
             alert("Please enter the Company Name.");
             txt_company.focus();
             return false;
            } 
			
//		   	if(opt_salutation.value.length ==0)
//            {            
//             alert("Please Enter Salutation");
//             opt_salutation.focus();
//             return false;
//            }   
            
		  	if(txt_firstname.value.length ==0)
            {            
             alert("First Name cant be null");
             txt_firstname.focus();
             return false;
            }             
            
		 	if(txt_lastname.value.length ==0)
            {            
             alert("Last Name cant be null");
             txt_firstname.focus();
             return false;
            }        
            	
		 	if(txt_street.value.length ==0)
            {            
             alert("Please Enter the Street");
             txt_street.focus();
             return false;
            } 
			
			if(txt_zip.value.length ==0)
            {            
             alert("Please Enter the Zip");
             txt_zip.focus();
             return false;
            } 
			
			if(txt_city.value.length ==0)
            {            
             alert("Please Enter the City");
             txt_city.focus();
             return false;
            } 
			
			if(txt_country.value.length ==0)
            {            
             alert("Please select the Country");
             txt_country.focus();
             return false;
            }
		    
		   if(txt_taxno.value.length ==0)
            {            
             alert("Please Enter VAT number");
             txt_taxno.focus();
             return false;
            }
			
           if(txt_email.value.length ==0)
            {            
             alert("Email cant be null");
             txt_email.focus();
             return false;
            } 
          
               str=txt_email.value;
           if(!echeck(str))
             {
             txt_email.focus();
             return false;
             }
            
              

            
        }   
   } 

    
