function addbookmark(url, title)
{
	if (document.all)
		window.external.AddFavorite(url,title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url,"");
	else
		alert('Sorry, your browser doesn\'t support this features');
}
function handleemptyquicksearch(form)
{
	if(form=="quick")
	{
		if (document.frm_search.s.value=="")
		{
			document.getElementById('s').value="Please enter search text here";
			return false;
		}
	}
	else if(form=="form")
	{
		if (document.frm_search2.s.value=="")
		{
			document.getElementById('s2').value="Please enter search text here";
			return false;
		}
	}
}

/*for validate contact us information.*/
function contact(val) {
	if(val=="contact_name") { document.contactus_form.contactus_name.value=''; }
	if(val=="contact_email") { document.contactus_form.contactus_email.value=''; }
	//if(val=="contact_subject") { document.contactus_form.contactus_subject.value=''; }
}
function contactus_form_validation() {
	if(document.contactus_form.contactus_name.value=='') {
		alert("Please enter your Name.");
		document.contactus_form.contactus_name.focus();
		return false;
	}			
	if(document.contactus_form.contactus_email.value=='') {
		alert("Please enter your Email.");
		document.contactus_form.contactus_email.focus();
		return false;
	}			
	if(document.contactus_form.contactus_email.value!='') { 
		var apos=document.contactus_form.contactus_email.value.indexOf("@"); 
		var dot=document.contactus_form.contactus_email.value.indexOf("."); 
		var last_apos=document.contactus_form.contactus_email.value.lastIndexOf("@"); 
		var last_dot=document.contactus_form.contactus_email.value.lastIndexOf("."); 
		var apos_dot=document.contactus_form.contactus_email.value.charAt(last_apos+1); 
		var fieldlength=document.contactus_form.contactus_email.value.length;
		//if(apos<1 || dot<1 || ( ((dot-apos)<2) || ((apos-dot)<2) ) || (fieldlength-dot)<2) 
		//apos and dot must in second index above. last apos and dot must not be in last index. last apos can not join last dot.
		if(!( apos>0 && dot>0 && (fieldlength-last_apos)>1 && (fieldlength-last_dot)>1 && (last_dot-last_apos)>1 && apos_dot!="." )) {
			alert("Please enter a valid Email.");
			document.contactus_form.contactus_email.focus();
			return false;
		} 
	}
	if(document.contactus_form.contactus_subject.value=='') {
		alert("Please enter Subject of email.");
		document.contactus_form.contactus_subject.focus();
		return false;
	}			
	if(document.contactus_form.contactus_message.value=='') {
		alert("Please enter Message.");
		document.contactus_form.contactus_message.focus();
		return false;
	}			
	document.getElementById("buttonReset").style.visibility='hidden';
	document.getElementById("buttonSend").style.visibility='hidden';
	return true;
}
/*for contact us form | assigning the right value.*/
function autoAI(selectedText) {
	if(selectedText=="General") {
		document.getElementById('contactus_message').value="Any General Message";
	} else if(selectedText=="Advertise") {
		document.getElementById('contactus_message').value="Change the information below.\n\nAds type: 125 x 125 pixels\nDuration: 1 month\nFrom: 01 May 2008\nTo: 01 June 2008\nPayment Method: paypal Or Alertpay\nReferring By (Email): friendname[ @ ]email.com\nDescription: -";
	} else if(selectedText=="Inquiry") {
		document.getElementById('contactus_message').value="Any doubts";
	} else if(selectedText=="Bugs Report") {
		document.getElementById('contactus_message').value="Report bugs found or script errors";
	} else if(selectedText=="Suggestion") {
		document.getElementById('contactus_message').value="Any through to share";
	} else if(selectedText=="Others") {
		document.getElementById('contactus_message').value="Just for fun.";
	}
}



/* Submit Form */
function submitform_validate()
{
	if(document.post.post_category.options[document.post.post_category.selectedIndex].value==-1)
	{
		alert("Please select one category.");
		document.post.post_category.focus(); return false;
	}
	if(document.post.post_title.value=="")
	{
		alert("Please enter work title.");
		document.post.post_title.focus(); return false;
	}
	if(document.post.web_url.value=="")
	{
		alert("Please enter work url.");
		document.post.web_url.focus(); return false;
	}
	if(document.post.web_url.value!="")
	{
		var reg = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;
		if(reg.test(document.post.web_url.value) == false) 
		{
			alert("Please enter valid URL.");
			document.post.web_url.focus(); return false;
		}
	}
	if(document.post.web_founder.value=="")
	{
		alert("Please enter work founder.");
		document.post.web_founder.focus(); return false;
	}
	if(document.post.web_founder_url.value!="")
	{
		var reg = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;
		if(reg.test(document.post.web_founder_url.value) == false) 
		{
			alert("Please enter valid URL.");
			document.post.web_founder_url.focus(); return false;
		}
	}
	if(document.post.web_location.value=="")
	{
		alert("Please enter work location.");
		document.post.web_location.focus(); return false;
	}
	if(document.post.web_author.value=="")
	{
		alert("Please enter post author.");
		document.post.web_author.focus(); return false;
	}
	if(document.post.web_author_email.value=="")
	{
		alert("Please enter post author email.");
		document.post.web_author_email.focus(); return false;
	}
	if(document.post.web_author_email.value!="")
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(document.post.web_author_email.value) == false) 
		{
			alert("Please enter email address");
			document.post.web_author_email.focus(); return false;
		}
	}
}

function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));

    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }

}