// JavaScript Document
	//Trim Functions
	var refreshIntervalId;
	var class_name;
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isAlphaNumeric(val){
	if (val.match(/^[a-zA-Z0-9]+$/))
	{
	return true;
	}
	else
	{
	return false;
	} 
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
	//End Trim Functions
function getAjaxRequest(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}
function buildQueryString(params) {
    var query = "";
    for (var i = 0; i < params.length; i++) {
        query += (i > 0 ? "&" : "")
            + escape(params[i].name) + "="
            + escape(params[i].value);
    }
    return query;
}
/*
*Fucntion for checking Validemail
*/
function isNumber(field){
		if(isNaN(field.value)){
		 field.value='';
		}
	}
/*
*Fucntion for checking Specail chracters if the field having the special character
*/
function isSpecilaCharacter(field)
{
	/*
	var valo 	= new String();
	var correct = new String();
	var characters = "<~`!@#$%^&*?'()_+=-[>{}]\|:;,\"/";
	var chars = field.value.split("");
	for (i = 0; i < chars.length; i++)
	{
		if (characters.indexOf(chars[i]) != -1)
		{
			valo 	+= chars[i];
		}else{
			correct += chars[i];
		}
	}
	if(valo.length>0)
	{
		alert(valo+" Charcters not allowed");	
	}
	field.value		= correct;
	return true;
	*/
}
/*
*Fucntion for checking the field value having the valid email
*/
function isValidEmail(email) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(email)){
		return true;
	}else{
		return false;
	}
}
	
function obayoo_popup(main_ele, drag_ele,id,reciever_id){
	$("hiddenDiv").innerHTML="";
	if(typeof window.innerHeight != 'undefined') {
		var h = document.documentElement.scrollHeight;//window.innerHeight;
		var w = window.innerWidth;
	} else {
		var h = document.documentElement.scrollHeight;/* document.documentElement.offsetHeight; */
		var w = document.documentElement.offsetWidth;
	}
	var theRoot 	= $('root');
	var theHandle 	= $('light');
	RainDrag.init(theRoot, theHandle, 10, w, 10, h );
	var element 	= main_ele;
	var scroll_top = getScrollTop();
	if(typeof window.innerHeight != 'undefined') {
		$(element).style.top = Math.round( scroll_top + ((window.innerHeight - $(element).getHeight()))/2)+'px';
		$(element).style.left = Math.round(document.body.offsetLeft + ((window.innerWidth - $(element).getWidth()))/2)+'px';
	} else {
		$(element).style.top = Math.round(scroll_top + ((document.documentElement.offsetHeight - $(element).getHeight()))/2)+'px';
		$(element).style.left = Math.round(document.body.offsetLeft + ((document.documentElement.offsetWidth - $(element).getWidth()))/2)+'px';
	}
	$(main_ele).style.display = 'block';
}
function popup_close(id){
	$(id).style.display='none';
	refreshIntervalId = setTimeout("load_messages()", 360000);
	//getMessageList(paths,'A','0','0')
}
function popup_close1(id){
	$("message_list_container").innerHTML="";
	
}
function getScrollTop() {
	if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) {
		return document.documentElement.scrollTop;
	}
	if (document.body && defined(document.body.scrollTop)) {
		return document.body.scrollTop;
	}
	return null;
}

function defined(o) {
	return (typeof(o)!="undefined");
}
function show_forgot_password_pop(){
	if($('forgot_password_pop').style.display=='none'){
		$('forgot_password_pop').appear();
	}else{
		$('forgot_password_pop').fade();
	}
}
function fncSubRplayMessageShowHide(msgId)
{
	if ($('divSubReplyMessage'+msgId).style.display == 'none')
	{
		$('divSubReplyMessage'+msgId).appear();
		$('spanSubReplyMessage'+msgId).className = 'disclosure open';
	}
	else 
	{
		$('divSubReplyMessage'+msgId).fade();
		$('spanSubReplyMessage'+msgId).className = 'disclosure close';
	}
}
function change_background_description(ele, lbl){
	if(ele.value == lbl ) ele.value = '';
}


function change_background_desc_blr(ele, lbl){
	if(ele.value == '') {
		ele.value = lbl;
		ele.style.color = '#999999';
	}
}

function change_background_join(ele, lbl){
	if(ele.value == lbl ) { ele.value = ''; ele.style.color = '#000000' }else{ ele.style.color = '#999999' }
}


function change_background_join_blr(ele, lbl){
	if(ele.value == '') { ele.value = lbl; ele.style.color = '#999999'; } else{ ele.style.color = '#000000'  }
}

function fncContactPost(){
	if( trim($('first').value) == '' )	
	{
		alert('Please enter your first name.');
		$('first').focus();
		return false;
	}
	if( trim($('last').value) == '' )	
	{
		alert('Please enter your last name.');
		$('last').focus();
		return false;
	}
	if( trim($('address').value) == '' )	
	{
		alert('Please enter your address.');
		$('address').focus();
		return false;
	}
	if( trim($('city').value) == '' )	
	{
		alert('Please enter your city.');
		$('city').focus();
		return false;
	}
	if( trim($('zip').value) == '' )	
	{
		alert('Please enter your zipcode.');
		$('zip').focus();
		return false;
	}
	if( $('county2').value < 2 )	
	{
		alert('Please select your county.');
		$('county').focus();
		return false;
	}
    if( trim($('email').value) == '' )
		{
		alert('Please enter your E-mail.');
		$('email').focus();
		return false;
		}
	if( !isValidEmail(trim($('email').value)) )
		{
		alert('Please enter a valid email.');
		$('email').focus();
		return false;
		} 	
    if( trim($('email2').value) == '' )
		{
		alert('Please confirm your email.');
		$('email2').focus();
		return false;
		}
    if( trim($('email2').value) != trim($('email').value) )
		{
		alert('The email addresses much match.');
		$('email2').focus();
		return false;
		}
    if( trim($('txtName').value) == '' )
		{
		alert('Please enter your iPhone number.');
		$('txtName').focus();
		return false;
		}
}	
function change_pass_field(){
	$('password_placeholder').style.display = 'none';
	$('pass').style.display = 'block';
	$('pass').focus();
}

function change_pass_placehoslder(){
	if( trim($('pass').value) == '' ){
		$('password_placeholder').style.display = 'block';
		$('pass').style.display = 'none';
	}
}
function change_template_height(){
	return;
	if($('mainbody').getHeight() < 550){
		if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) $('mainbody').style.height='550px';
			$('mainbody').style.minHeight='550px'; 
	}
	/*
	if(Prototype.Browser.IE==true){
			$('mainContainerInner').style.paddingRight = '5px';
		}else if(Prototype.Browser.Gecko==true){
			$('mainContainerInner').style.paddingRight = '14px';
		}
	*/
}
function height_adjust(id){
	if($(id).getHeight() < 550){
		if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) $(id).style.height='550px';
			$(id).style.minHeight='550px'; 
	}
}
function change_homepage_height1(){
	if($('height_div').getHeight() < 250){
		if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) $('height_div').style.height='250px';
			$('height_div').style.minHeight='250px'; 
			
	}
}
function change_homepage_height(){
	if($('mainbody').getHeight() < 550){
		if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) {
			//$('mainContainerInner').style.paddingRight = '14px';
		}else{
			//$('mainContainerInner').style.paddingRight = '5px';
		}
		
		if(Prototype.Browser.IE==true){
			$('mainContainerInner').style.paddingRight = '5px';
		}else if(Prototype.Browser.Gecko==true){
			$('mainContainerInner').style.paddingRight = '14px';
		}
		//alert(Prototype.Browser.Gecko);
	}
}
function share_somthing(id, name){
	$('group_contaner').firstChild.data = name;
	$('txtGroupShareWith').value = id;
}

function abcd(inputfeild, e, dec) {
	var key;
	var keychar;
	
	if (window.event)
		 key = window.event.keyCode;
	else if (e)
		 key = e.which;
	else
		 return true;
	keychar = String.fromCharCode(key);
	
	var val = inputfeild.value;
	if(val && keychar == '.'){
		if(val.split(".").length > 1){
			return false;
		}
	}
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		 return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		 return true;
	// decimal point jump
	else if ((dec) && (keychar == ".")) {
		 //inputfeild.form.elements[dec].focus();
	 return true;
	 }	else
		 return false;
};


function enter_key_post(e, formid, t){
	//alert(window.parent.location) ;  return;
	if (window.event){
		var key = window.event.keyCode;
	}else if (e){
		 var key = e.which;
	}else{
		 //return true;
	}
	if(key==13){
		$(formid).submit();
		if(t=='L') window.parent.location = window.parent.location;
	}
}

function link_change(ele){
	class_name = ele.className;
	ele.className = 'user_links_over';
}

function link_over(ele){
	ele.className = class_name;
}

function link_change_connect(ele){
	class_name = ele.className;
	ele.className = 'obayoo_connect_hover';
}

function go_to(url){
	window.location = url;
}

function change_style(ele){
	class_name = ele.className;
	ele.className = 'button_style_over';
}

function change_style_over(ele){
	ele.className = class_name;	
}
function change_style_long(ele){
	class_name = ele.className;
	ele.className = 'button_style_long_over';
}
function format_sel( input ) {
var aTag =  '';
var eTag =  '';
input.focus();

//FOR IE
if    (typeof document.selection != 'undefined') {
        var range = document.selection.createRange();
        var insText = range.text;
        range.text = aTag + insText + eTag; //
        range = document.selection.createRange();
    if    (insText.length == 0) {
            range.move('character', -eTag.length); //
    }    else {
            range.moveStart('character', aTag.length + insText.length + eTag.length);      // 
   }
   range.select();

}   else  {  

// FOR Gecko Browser

if    (typeof input.selectionStart != 'undefined') {

    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end); //  

    var pos;
    if    (insText.length == 0) {
        pos = start + aTag.length;
    } else {
        pos = start + aTag.length + insText.length + eTag.length; //
    }
   input.selectionStart = pos;
   input.selectionEnd = pos;

    }
}

}

function thread_on_off(paths,param,start)
{
	var start = 0;
	var oOptions = {
		method: "post",
		parameters: { },
		onFailure: function (oXHR, oJson) {
			//alert("An error occurred: " + oXHR.status);
		},
		onSuccess: function(transport){
		   var response = transport.responseText;
		   if (param == 'TAG')
		   {
			   window.location=window.location;
		   }
		   if (param == 'SEARCH')
		   {
			   $('frmsearch').submit();
		   }
		   else if (param == 'FEED')
		   {
			   eval(list_feed_messages(paths)); /*paths means feed_id*/
		   }
		   else if(param == 'A' || param == 'R' || param == 'S' || param == '')
		   {
			   eval(getMessageList(paths,'A',start));
			  // eval(getMessageList(paths,'R',start));
			   eval(getMessageList(paths,'S',start));
			   eval(list_favourite_msg('navigation_childs_5'));
		   }
		   else if(param == 'G' || param == 'SG')
		   {
			   eval(getMessageList(paths,'G',start));
			   eval(getMessageList(paths,'SG',start));
		   }
		   else if(param == 'P' || param == 'SP')
		   {
			   eval(getMessageList(paths,'P',start));
			   if($('navigation_childs_8')) eval(getMessageList(paths,'SP',start));
		   }
		   else
		   {
		   		eval(getMessageList(paths,param,start));
		   }
	   }
	};
	var oRequest = new Ajax.Updater({ 
		//success: "divCustomerInfo"
	}, path+"cpanel/thread_vew", oOptions);	
	
}
function removeFile(id,name,divId)
{
	$(id).remove();
	$(divId).innerHTML ='<input type="file" name="'+name+'" id="'+id+'">';
}
function collegueSort(){}

function imagepreload(image_url){
	if (document.images)
    {
      preload_image_object = new Image();
      // set image url
       var i = 0;
       for(i=0; i<=3; i++) {
         preload_image_object.src = image_url[i];
	   }
    }	
}

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}