window.onload=jQuery(document).ready(function(){if (jQuery('#divSignCreate')) jQuery('#divSignCreate').show();});

function loadFB(s, u)
{
	if (typeof(s)=='undefined' || s != 'emp')
		jQuery.noConflict();
    jQuery(document).ready(function($) {
      jQuery('a[rel*=facebox]').facebox({
        loadingImage : u+'j/facebox/loading.gif',
        closeImage   : u+'j/facebox/closelabel.gif'
      }) 
    })
}
	
var popUpWin=pwmkm=0;
function puWin(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
	  if (!popUpWin.closed)
	    popUpWin.close();
  }  
 //pwmkm = Math.floor(Math.random()*11);
 //popUpWin = open(URLStr, 'popUpWin'+pwmkm, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top);
 popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top);
  
}

function $F(id){
	return jQuery('#'+id).val();
}
function $R(id){
	 var tmp = jQuery("input[name="+id+"]:checked").val();
	 if (typeof tmp == "undefined")
	 	return '';
	 else
	 	return tmp;
}
function selOpt(oln, ListVal)
{	
	for (i=0; i < oln.length; i++)
	{
		if (oln.options[i].value == ListVal)
		{
			oln.selectedIndex = i;
			break;
		}
	}
}

function lding(dw, id, path, extra)
{
    path = (typeof path == "undefined" ? "" : path);
	extra = (typeof path == "undefined" ? "" : extra);
    switch(dw)
    {
        case '00': $(id).hide(); break;
        case '01': $(id).innerHTML = '<img src="'+path+'i/load-16w.gif" width="16" height="16" '+extra+' style="width:16px;height:16px;" />'; $(id).show();break;
    
        case '10': $(id).hide(); break;
        case '11': $(id).innerHTML = '<img src="'+path+'i/load-16g.gif" width="16" height="16" '+extra+' style="width:16px;height:16px;" />'; $(id).show();break;

		case '20': $(id).hide(); break;
        case '21': $(id).innerHTML = '<img src="'+path+'i/loadH.gif" width="43" height="11" '+extra+' style="width:43px;height:11px;" />'; $(id).show();break;
		
		case '30': $(id).hide(); break;
        case '31': $(id).innerHTML = '<img src="'+path+'i/loadH.gif" width="12" height="12" '+extra+' style="width:12;height:12px;" />'; $(id).show();break;
    }
}

function clearVal(obj,txt){
	if(obj.value==txt)
		obj.value = '';
	else if	(obj.value == '')
		obj.value = txt;
}


//-------------------- Forward Job Function 

function forwardMail()
{
	
	cur_job_id=$('fwdJid').value;

	username=$('username').value;
	userEmail=$('userEmail').value;
	forwardTo=$('forwardTo').value;
	vImageCodP=$('vImageCodP').value;
	str = $H({btnSubmit:'forwardEmail',username:username,userEmail:userEmail,forwardTo:forwardTo,cur_job_id:cur_job_id,vImageCodP:vImageCodP}).toQueryString();
//alert(str);
	/*$('sprldgg').show();
	$('S-btn').hide();*/
	
	new Ajax.Request('forward-email.php', 
		{
			method: 'post', 
			parameters: str,
			onSuccess:_forwardMail,
			onLoading: lding('21','mkm_fwdJob')
		});
}
function _forwardMail(msg)
{
	var a = msg.responseText;
	$('mkm_fwdJob').update(a);
	
	/*if(t[0]=='SUC')
	{
		new Effect.Opacity('divMsg', {to: 0.0, from: 1.0, afterFinish:function(){$('divMsg').innerHTML = t[1]; Effect.Appear('divMsg'); Effect.Fade('divMsg', {duration: 10.0})}});	
	
	}
	else if(t[0]== 'ERR')
	{
			new Effect.Opacity('divMsg', {to: 0.0, from: 1.0, afterFinish:function(){$('divMsg').innerHTML = t[1]; Effect.Appear('divMsg'); Effect.Fade('divMsg', {duration: 10.0})}});	
	}*/
}

function changePassword()
{
	oPass=$('oPass').value;
	nPass=$('nPass').value;
	cnPass=$('cnPass').value;
	p = $H({Submit:'ChangePassword',oPass:oPass,nPass:nPass,cnPass:cnPass}).toQueryString();
	
	new Ajax.Request('change-password.php', 
		{
			method: 'post', 
			parameters: p,
			onSuccess:_changePassword,
			onLoading: lding('21','mkm_divContent')
		});
}
function _changePassword(msg)
{
	var a = msg.responseText;

	$('mkm_divContent').update(a);
}

function replaceAllChar( str, replacements ) 
{
    for ( i = 0; i < replacements.length; i++ ) {
        var idx = str.indexOf( replacements[i][0] );

        while ( idx > -1 ) {
            str = str.replace( replacements[i][0], replacements[i][1] );
            idx = str.indexOf( replacements[i][0] );
        }

    }

    return str;
}

function showHide(show,hide){

	show = show.split('#');
	hide = hide.split('#');
	
	if(hide!='null'){
		for(i=0; i<hide.length; i++){
			if($(hide[i]))
				$(hide[i]).style.display = 'none';
			//else
				//alert('Unable to hide: '+hide[i]);
		}
	}

	if(show!='null'){
		for(i=0; i<show.length; i++){
			if($(show[i]))
				$(show[i]).style.display = '';
			//else
				//alert('Unable to show: '+show[i]);
		}
	}
}

function resetFieldF(obj,currentVal,valToCheck,valToSet)
{
	if( currentVal == valToCheck )
	obj.value=valToSet;
}
function resetFieldB(obj,currentVal,valToSet)
{
	if( currentVal == '' )
	obj.value=valToSet;
}

var _ajx = function(u, d, c, id, i, dt, pm)
{
	dt = (typeof(dt) == "undefined" ? "string" : dt);	// return type
	pm = (typeof(pm) == "undefined" ? "post" : pm);	// posting method

	if(typeof(id)!='undefined' && id != '')
	{
		i = (typeof(i) == "undefined" ? "1" : i);
		switch(i)
		{
			case "1": i='i/load-16g.gif'; break;
			case "2": i='i/ldr-big.gif'; break;
			case "3": i='i/ldr-arr.gif'; break;
			default: i='i/load-16g.gif'; break;
		}
		var ldImg = jQuery('<img/>').attr({'src': i,'alt': 'Wait ... '});

		jQuery('#' + id).ajaxStart(function(){
		    jQuery(this).append(ldImg);
			jQuery(this).show();
		});
		jQuery('#' + id).ajaxStop(function(){
			ldImg.remove();
			jQuery(this).hide();
			jQuery(this).unbind();
		});
	}

	jQuery.ajax({url:u, type:pm, data:d, dataType:dt, success:c});
}


function errMessage(errMessage)
{

	if (errMessage != '')
	return '<div id="msgi"><div class="msgbge"><ul><li class="sp18"><img src="../i/ico/ico_warn.gif" /></li><li class="msgtxti">'+errMessage+'</li></ul></div></div>';
	return false;
}

function sucMessage(message)
{
	return '<div id="msgi"><div class="msgbgs"><ul><li class="sp18"><img src="../i/ico/yestick_btn.gif" /></li><li class="msgtxti" >'+message+'</li></ul></div></div>';
}


function reloadBlock(f)
{
	//$.ajax(file,'',_reloadBlock);	
	$.ajax({url:f, success:function(data){
		  updateVal('show_table',data);
		 }
	});
}

function shID(id,style)
{

	if (style=='none')
			jQuery('#'+id).hide();
		else
			jQuery('#'+id).show();
}
function getValue(id)
{
	return jQuery('#'+id).val();
}

function showMsg(id,msg)
{
	shID(id,'');
	jQuery('#'+id).append(msg);
	jQuery('#'+id).fadeOut(5000,function(){jQuery('#'+id).html('');});
}

function fsClose()
{
	jQuery(document).trigger('close.facebox');
}

function updateVal(id,val)
{
	jQuery('#'+id).html(val);	
	
}

function insertVal(id,v)
{
	jQuery('#'+id).val(v);	
}

function toggleID(id)
{
	jQuery('#'+id).toggle();
}

function isCh(id)
{
	return jQuery('#'+id).attr('checked');
	
}
function setClass(id,cls)
{
	 jQuery('#'+id).attr('class',cls);
}


function getCatagory(catID,classID,status)
{
	for(i=0;i<=4;i++)
		$('#'+i).attr('class','');
	//$('img#imgProfileBar').css('width', t[9]+'%');
	$('#'+classID).attr('class','current');  
	if ($('#'+classID).attr('class')=='current')
		$.post('jx/cartAjx.php',  {f:'progCatagories',catID:catID}, _getCatagory);
}

function _fb(url)
{
	jQuery(document).ready(function(){jQuery.facebox({ajax: url})} );
}

function _S(id)
{
	jQuery('#'+id).show();
}

function _H(id)
{
	jQuery('#'+id).hide();
}

function getSV(obj)
{	// Get Single value of Radio Button or Checkbox
	if (!obj)
		return "RozeeError";
	for(var i=0;i<obj.length;i++){
		if (obj[i].checked){
			return(obj[i].value);
			break;
		}
	}
}

function gpt(val)
{	// Google Page Track
	pageTracker._trackPageview(val);
}

function textKey(t,element,maxlength){
	supportsKeys = true;
	calcCharLeft(t,element,maxlength);
}

function calcCharLeft(t,element,maxLength){
	clipped = false;
	if (element.value.length > maxLength) { 
		element.value = element.value.substring(0,maxLength);
		charleft = 0;
		clipped = true;
	} else {
		charleft = maxLength - element.value.length;
	}
	if (t=='html')
		jQuery('#spMoreChar').html(charleft);
	else
		jQuery('#spMoreChar').val(charleft);
	return clipped;
}

function upCountry(co,lo,ciu)
{
	data = {f:'gcities', co:co};
	_ajx('inc/misc.php', data, function(x){
						jQuery('#'+ciu).html(x.msgV);
						}, lo, '1', 'json');
}