var B=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown';
function field_focus(sFName)
{
	var field_text;
	var obj = document.getElementById(sFName);
 
	eval("field_text = "+sFName+"_text;");
	
//	alert(obj.value);
	 if(obj.value == field_text) {
        obj.value = "";
    }
    
}

function field_blur(sFName)
{
	var field_text;
	var obj = document.getElementById(sFName);
	eval("field_text = "+sFName+"_text;");
	
	 if(obj.value == '') {
        obj.value = field_text;
    }
}

function loadSNInfo(sSNNum,sType,iPackID)
{
//	alert($('#request_sn').val());
	$.post( portal_path+'/rma-returns'
			, { action : 'getSNInfo'
				, request_sn : sSNNum 
				, iPackID : iPackID 
				, type : sType }
			,function(info)
			{
				if($('#sn_details'))
					$('#sn_details').html(info);
			} 
			);
}

function getScrollY() 
{
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) 
	{
		scrOfY = window.pageYOffset;
	}
	else if( document.body && document.body.scrollTop ) 
	{
		scrOfY = document.body.scrollTop;
	} 
	else if( document.documentElement && document.documentElement.scrollTop ) 
	{
		scrOfY = document.documentElement.scrollTop;
	}
	if(130 > scrOfY)
  		scrOfY = 130;
  	scrOfY += iTopPadding
  	
  	return scrOfY;
}

function mousePageXY(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
  	try
  	{
  		x = e.clientX +  document.body.scrollLeft - document.documentElement.clientLeft;
	    y = e.clientY +  document.body.scrollTop - document.documentElement.clientTop;
	    
  	}
  	catch(e)
  	{
  		x = e.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft;
	    y = e.clientY + document.documentElement.scrollTop - document.documentElement.clientTop;
  	}
  }

  return {"x":x, "y":y};
}

var iTW;
var iTH;

function setOnlaod()
{
	var x = document.getElementsByTagName('body')[0];
  iTW = x.clientWidth ;
  iTH = x.clientHeight ;
}

function showOwerlayMessqge()
{
	
	document.getElementById("sc_frm").style.display = "";
	$( '#sc_frm' ).css( { width : screen.availWidth + 'px', height : screen.availHeight + 'px', position : 'fixed' } );
	$( '#popup_overlay' ).css( { width : screen.availWidth + 'px', height : screen.availHeight + 'px', position : 'fixed' } );
}



function hideOwerlayMessqge()
{
	document.getElementById("sc_frm").style.display = "none";
}

var name = new Array();
var host = new Array();
var domain = new Array();


function sendm(id)
{
	var em;
	if(name[id] && host[id] && domain[id] && (obj = document.getElementById(id)))
	{
		em = name[id]+String.fromCharCode(32*2)+host[id]+String.fromCharCode(23*2)+domain[id];
		obj.href = "mailto:"+em;
		obj.innerHTML = em;
	}
}

function hideLogin()
{
	document.getElementById("login").value="";
	document.getElementById("psw").value="";
	document.getElementById("login_box").style.display = "none";
	$('#auth_error').html('');
	hideOwerlayMessqge();
}

function showLogin()
{
	var iTW = document.documentElement.clientWidth;
	hideRemPass();
	document.getElementById("login_box").style.left = iTW/2 - 215 +"px";
	document.getElementById("login").value="";
	document.getElementById("psw").value="";	
	$('#auth_error').html("");
	$('#forgot_passwd').show();
	showOwerlayMessqge();
	document.getElementById("login_box").style.display = "";
}

function remPass()
{
	document.getElementById("log_pass").style.display = "none";
	document.getElementById("forg_pass").style.display = "";
	document.getElementById("btn_login").style.display = "none";
	document.getElementById("btn_send").style.display = "";
	$('#forgot_passwd').hide();
	$('#restore_error').text('');
	$('#auth_error').html("");
}

function sendRemPass()
{
	$.post( portal_path+'/index.html'
			,{ action : 'restorePassword'
				,login: $('#login').val()}
			,function(script){eval(script);} 
			);
}

function hideRemPass()
{
	document.getElementById("log_pass").style.display = "";
	document.getElementById("forg_pass").style.display = "none";
	document.getElementById("btn_login").style.display = "";
	document.getElementById("btn_send").style.display = "none";
	$('#forgot_passwd').show();
	$('#restore_error').text('');
	$('#auth_error').html("");
}

function login_()
{
//	return false;
	$.post( portal_path+'/index.html'
			,{ action : 'auth'
				,login: $('#login').val()
				,passw: $('#psw').val()}
			,function(script){
				eval(script);
				return false;
			} 
			);
	return false;
}

function showOwerlayMessage()
{
	showOwerlayMessqge();
}

function hideOwerlayMessage()
{
	hideOwerlayMessqge();
}

function showJsError(sMessage)
{
	document.getElementById("js_error").style.left = mCur.x - 390+"px";
	document.getElementById("js_error").style.top =  mCur.y - 90+"px";
	showOwerlayMessage();
	document.getElementById("error_message").innerHTML = sMessage;
	document.getElementById("js_error").style.display = "";
}

function hideJsError()
{
	document.getElementById("error_message").innerHTML = "";
	document.getElementById("js_error").style.display = "none";
	hideOwerlayMessage();
}

var mCur;

document.onmousemove = function(e)
{
	mCur = mousePageXY(e);
}

function setMouseCoords(e)
{
	mCur = mousePageXY(e); 
}


function _alert(sMess)
{
	return jAlert(sMess);
}

var iPackID;

function hideDelete()
{
	tAlert.close();
}

function showDelete(iID)
{
	iPackId = iID;
	tAlert.init("sc_frm","delete");
	tAlert.show();
//	toArchivePackage();
}

function test()
{
	alert("dasfdsf");
}

function toggleAdderss()
{
	var sAddrFields = ["contactaddress","phoneaddress","emailaddress","alternative_address","countryaddress"];
	for(i=0;i<sAddrFields.length; i++)
	{
		$("#"+sAddrFields[i]).toggle();
		$("#"+sAddrFields[i]+"_def").toggle();
	}
}

function alertReload(sMess)
{
	jAlert(sMess,"Alert!!!",Reload);
}


function Reload()
{
	document.location.href = sCurPage;
}
