var CMSROOTPATH = 'http://'+window.location.host; 
var ROOTURLPATH = "http://"+window.location.host+"/";
var TODBFILEPATH = CMSROOTPATH+'/2db';
// JavaScript Document
function signinbx(id, counter){
	if(counter == 1){
		$.blockUI(flvar1, {width:'600px'});
	}else if(counter == 2){
		$.blockUI(flvar2, {width:'600px'});
	}else if(counter == 3){
		$.blockUI(flvar3, {width:'600px'});
	}else if(counter == 4){
		$.blockUI(flvar4, {width:'600px'});
	}else if(counter == 5){
		$.blockUI(flvar5, {width:'600px'});
	}else if(counter == 6){
		$.blockUI(flvar6, {width:'600px'});
	}else if(counter == 7){
		$.blockUI(flvar7, {width:'600px'});
	}else if(counter == 8){
		$.blockUI(flvar8, {width:'600px'});
	}
}
function echeck(str)
	{
		var at="@"
		var dot="."
		var space=" ";
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
			return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
			return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
			return false
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
			return false
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
			return false
		}
		if (str.indexOf(dot,(lat+2))==-1)
		{
			return false
		}
		return true
	}
	function addtoshare(){	
		show_shar_form('share');
		show_shar_form();
	}
	function addslashesShare(str) {
		str=str.replace(/\\/g,'\\\\');
		str=str.replace(/\'/g,'\\\'');
		str=str.replace(/\"/g,'\\"');
		str=str.replace(/\0/g,'\\0');
		return str;
	}
	function validate_share_data(id){
	var emailID=jQuery.trim($("#share_emailid"+id).val());
	var url = $("#shareURL"+id).val();
	var title=$("#shareTitle"+id).val();
	var shareMessage = jQuery.trim($("#shareMessage"+id).val());
	var flag = 0;
	var share_urmail=jQuery.trim($("#share_urmail"+id).val());
	var link_url='<a href="http://luxpresso.com/" style="font:bold 12px/16px Arial; color:#0066CC; text-decoration:underline;" title="luxpresso.com">luxpresso.com</a>, give it a try.';
	var default_comment="Hey! check this awesome post out on luxpresso.com";
	var comment=default_comment+link_url;
	form_comment=default_comment;
	
	if((emailID==null)||(emailID=="")){
		errmsg	=	"Please Enter Your Mail-ID";
		$("#share_emailid"+id).focus();
		flag=1;
	}
	var url = $("#shareURL"+id).val();
	//alert(share_urmail);
	if(share_urmail==""){
		//alert("Please Enter From Email ID");
		errmsg	=	"Please Enter Your Mail-ID";
		$('#share_urmail').focus();
		flag=1;
		//return false;
	}
	 $("#showerrormsg").hide();
	if(flag == 0){

		var email_id=emailID.split(",");
		for(var i = 0; i < email_id.length; i++){
			if(email_id[i].length>1){
				if (!echeck(email_id[i],1,0)){
					$("#share_emailid"+id).focus();
					$("#showerrormsg"+id).html("Oops! Email ID that you entered is invalid.");
				 	$("#showerrormsg"+id).show();
					return false;
				}
			}
		}
		var f_subject = 'Hey! check this awesome post out on luxpresso.com!';
		var f_body ='<div style="color: #333;padding-left:10px;padding-top:10px;font-size:14px;"><strong>Hi there,</strong></div><div style="font:12px/16px Arial; color:#333; text-decoration:none;">Here is something awesome: '+title+' that I came across today and thought it might interest you as well.Check it out!<br><br> <a href="'+url+'" style="font:bold 12px/16px Arial; color:#0066CC; text-decoration:underline;" title='+title+'>'+title+'</a><br><br>Cool right? Why don\'t you forward this to your buddy list? For once I am sure that your pals won\'t complain :)<br><br>'+addslashesShare(shareMessage)+'<br><br>Cheers!</div> <br><br>';
		///alert(f_body);
		for(var i = 0; i < email_id.length; i++){
			if(email_id[i].length>1){
				if (echeck(email_id[i],1,0)!=false){
					$.post(ROOTURLPATH+"sendmail_invite.php", {"f_to": email_id[i], "url":url, "f_subject": f_subject, "f_body": f_body, "f_from": share_urmail}, function(data){ 
					});
				}
			}
		}
		$("#showthanksmsg"+id).html('Thank you for spreading the word. For once your friend won\'t complain :)');
		setTimeout($.unblockUI, 1000); 
	}else{
		 $("#showerrormsg"+id).html(errmsg);
		 $("#showerrormsg"+id).show();
	}
}
function doRating(text,id){
	for(i=1;i<=10;i++){
		tagid="rImage"+i;
		if(i % 2 == 1){
			document.getElementById(tagid).src="http://luxpresso.com/images/halfempty-rating.gif";
		}
		else{
			document.getElementById(tagid).src="http://luxpresso.com/images/halfempty-rating-rgt.gif";
		}
	}
	cnt=text*2;
	for(i=1;i<=cnt;i++){
		tagid="rImage"+i;
		modi = i%2;
		if(modi == 0){
			document.getElementById(tagid).src="http://luxpresso.com/images/halffull-rating-rgt.gif";
		}
		else{
			document.getElementById(tagid).src="http://luxpresso.com/images/halffull-rating.gif";
		}
	}
	disptext = text + " Star";
	if (document.getElementById){
		x = document.getElementById(id);
		x.innerHTML = '';
		//x.innerHTML = disptext;
	}else if (document.all){
		x = document.all[id];
		//x.innerHTML = disptext;
	}else if (document.layers){
		x = document.layers[id];
		text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		//x.document.write(text2);
		x.document.close();
	}
}

function clearRating(){
	for(i=1;i<=10;i++){
		tagid="rImage"+i;
		if(i % 2 == 1){
			document.getElementById(tagid).src="http://luxpresso.com/images/halfempty-rating.gif";
		}
		else{
			document.getElementById(tagid).src="http://luxpresso.com/images/halfempty-rating-rgt.gif";
		}
	}
	disptext = "";
	id="test"
	if (document.getElementById){
		x = document.getElementById(id);
		x.innerHTML = '';
		//x.innerHTML = disptext;
	}else if (document.all){
		x = document.all[id];
		//x.innerHTML = disptext;
	}else if (document.layers){
		x = document.layers[id];
		//text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		//x.document.write(text2);
		x.document.close();
	}
}
	function submitRating(ratingVal, contentId){
		$.post("http://luxpresso.com/2db/submitRating.php",{"ratingVal": ratingVal, "contentId" : contentId}, function(data){
				//alert(data);		
				$("#showuserrating").html(data);
				$("#mainRating").html("<span class='b_11' style='display:inline-block; padding:4px'><b>Thank you for rating!</b></span>");
				if(readCookie("RATING")){
					var cookieValue = readCookie("RATING") + "~" + contentId;
					Set_Cookie("RATING", cookieValue, "1");
				}else{
					Set_Cookie("RATING", contentId, "1");
				}
				
				
		});
	}

	function chkRated(CookieName, contentId){
		if(readCookie(CookieName)){
			var cookieVal = readCookie(CookieName);
			var cookieArr = cookieVal.split("~");
			if(cookieArr.length > 1){
				if(cookieArr.inArray(contentId)){
					$("#mainRating").html("<span class='b_11' style='display:inline-block; padding:4px'><b>You have already rated this post!</b></span>");
				}
			}else{
				if(cookieVal == contentId){
					$("#mainRating").html("<span class='b_11' style='display:inline-block; padding:4px'><b>You have already rated this post!</b></span>");
					
				}
			}
		}

	}

	Array.prototype.inArray = function (value){
		// Returns true if the passed value is found in the
		// array. Returns false if it is not.
		var i;
		for (i=0; i < this.length; i++){
			if (this[i] == value) {
				return true;
			}
		}
		return false;
	};

