
var chars="abcdefghijklmnopqrstuvwxyz0123456789";function createCookie(name,value,days)
{if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name)
{createCookie(name,"",-1);}
function registration_disable_option(field_name)
{field_name.disabled=true;}
function registration_enable_option(field_name)
{field_name.disabled=false;}
function check_blank_fields(field_name,s)
{if(field_name.value=="")
{var error="Cannot leave the "+s+" field blank";alert(error);return false;}
return true;}
function frmgetname(name,val,frm)
{if(val.checked)
{frm.author.value=name;frm.author.disabled=true;}
else
{frm.author.value="";frm.author.disabled=false;}}
function getRndStr(field_name)
{anum=new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');nums=new Array('0','1','2','3','4','5','6','7','8','9');var endpass="";for(i=0;i<2;i++)
{nextChar=Math.floor(Math.random()*52);nextDig=Math.floor(Math.random()*10);}
for(j=0;j<2;j++)
{nextDig=Math.floor(Math.random()*10);endpass=nums[nextDig]+endpass;}
for(j=0;j<6;j++)
{nextChar=Math.floor(Math.random()*52);endpass=anum[nextChar]+endpass;}
field_name.value=endpass;}
function reset_field(field_name)
{field_name.value='';}
function enable_disable_field(field_name)
{if(field_name.disabled==true)
{field_name.disabled=false;}
else
{field_name.disabled=true;}}
function enable_disable_field_onload(flag,field_name)
{if(flag==false)
{field_name.disabled=false;}
else
{field_name.disabled=true;}}
function check_max_count(field_name,max_limit)
{if(count_characters(field_name)>max_limit)
{alert('you can not Enter more than '+max_limit+' Characters');return false;}}
function count_characters(field_name)
{return(field_name.value.length);}
function display_total_characters(field_name)
{total=count_characters(field_name);return total;}
function show_text(divId,val,e)
{var myDiv=document.getElementById(divId);if(val<=-1&&(e.keyCode!=8&&e.keyCode!=46&&e.keyCode!=37&&e.keyCode!=38&&e.keyCode!=39&&e.keyCode!=40&&e.keyCode!=16))
{alert("You have exceeded the limit.");return false;}
else
{myDiv.innerHTML=val;}}
function showMyDiv(mydiv)
{var img_name=document.ad_upload.ad_image.value;mydiv.style.visibility="visible";var pre_img=document.getElementById('preview_img');pre_img.src=img_name;}
function show_list(mydiv)
{var mydiv=document.getElementById('mydiv');mydiv.style.visibility="visible";}
function confirm_delete(field_name,type)
{var field_name;if(field_name.checked==true)
var status=(confirm("Are you sure you want to delete this "+type+"? \nClick Submit to Delete it."));if(!status)
field_name.checked=false;}
function confirm_ie()
{if(navigator.appName!="Microsoft Internet Explorer")
{alert("Compatible with Microsoft Internet Explorer Only");}}
function compareDate(date,date1)
{if(Date.parse(date.value)>Date.parse(date1))
{alert("Hire date cannot be greater than today's date");return false;}
return true;}
function disable_option()
{
	document.form1.paper_upload_type[1].disabled = true;
	document.form1.paper_upload_type[0].disabled = false;
	document.form1.paper_upload_type[0].checked = true;

	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. Start
	document.form1.paper_upload_type[2].disabled = true;
	document.form1.paper_upload_type[3].disabled = true;
	document.form1.paper_upload_type[4].disabled = true;
	document.form1.paper_upload_type[5].disabled = true;
	document.form1.paper_upload_type[6].disabled = true;
	document.form1.paper_upload_type[7].disabled = true;
	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. End
}
function enable_option()
{document.form1.paper_upload_type[0].disabled=false;document.form1.paper_upload_type[1].disabled=false;}
function paper_enable_option()
{
	document.form1.paper_upload_type[0].disabled = false;
	document.form1.paper_upload_type[1].disabled = false;
	document.form1.paper_upload_type[1].checked = true;

	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. Start
	document.form1.paper_upload_type[2].disabled = false;
	document.form1.paper_upload_type[3].disabled = false;
	document.form1.paper_upload_type[4].disabled = false;
	document.form1.paper_upload_type[5].disabled = false;
	document.form1.paper_upload_type[6].disabled = false;
	document.form1.paper_upload_type[7].disabled = false;
	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. End
}
function pdf_enable_option()
{
	document.form1.paper_upload_type[1].disabled = false;
	document.form1.paper_upload_type[1].checked = true;
	document.form1.paper_upload_type[0].disabled = true;

	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. Start
	document.form1.paper_upload_type[2].disabled = true;
	document.form1.paper_upload_type[3].disabled = true;
	document.form1.paper_upload_type[4].disabled = true;
	document.form1.paper_upload_type[5].disabled = true;
	document.form1.paper_upload_type[6].disabled = true;
	document.form1.paper_upload_type[7].disabled = true;
	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. End
}
function press_release_enable_option()
{
	document.form1.paper_upload_type[0].disabled = false;
	document.form1.paper_upload_type[1].disabled = false;
	document.form1.paper_upload_type[0].checked = true;

	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. Start
	document.form1.paper_upload_type[2].disabled = true;
	document.form1.paper_upload_type[3].disabled = true;
	document.form1.paper_upload_type[4].disabled = true;
	document.form1.paper_upload_type[5].disabled = true;
	document.form1.paper_upload_type[6].disabled = true;
	document.form1.paper_upload_type[7].disabled = true;
	//Added by Pankaj, for mantis issue 000054. Dt: 15/09/2010. End
}
function del_community()
{if(confirm('Are you sure you want to delete this community?'))
return true;else
return false;}
function confirm_sponsor()
{if(confirm('Are you sure you want to proceede to sponsor this page? You will get logged out of your current account.'))
return true;else
return false;}
function doedit(id,action)
{if(action=='show')
{document.getElementById(id).style.visibility="visible";document.getElementById(id).style.position="static";}
if(action=='hide')
{document.getElementById(id).style.visibility="hidden";document.getElementById(id).style.position="absolute";}}
function IsNumeric(strString)
{var strValidChars="0123456789.";var strChar;var blnResult=true;if(strString.length==0)return false;for(i=0;i<strString.length&&blnResult==true;i++)
{strChar=strString.charAt(i);if(strValidChars.indexOf(strChar)==-1)
{blnResult=false;}}
return blnResult;}
function frmsubmit(id1,id2,tempvar,action)
{var commentid="edit_comments"+id1;var ratingid="editrating"+id2+""+tempvar;var rating="";if(id1!=0)
{var comment=document.comment.elements[commentid].value;}
if(id2!=0)
{var rating=document.comment.elements[ratingid].value;}
if(action=="update"&&comment=="")
{alert("comment cannot be blank ");document.comment.elements[commentid].focus();}
else if(action=="update"&&(rating==""||rating>5||rating<0||(!IsNumeric(rating)))&&id2!=0)
{if(rating=="")
{alert("Rating cannot be blank ");}
else if(rating<0||rating>5)
{alert("Rating Must be between 0 to 5");}
else if(!IsNumeric(rating))
{alert("Please Enter Number for Rating");}
document.comment.elements[ratingid].focus();}
else
{document.comment.elements['hidaction'].value=action;document.comment.elements['hratingid'].value=id2;document.comment.elements['hid'].value=id1;document.comment.elements['tempvar'].value=tempvar;document.comment.submit();}}
function div_visible(id,text,textb,comm_id,type_flag)
{var e=document.getElementById(id);var text=document.getElementById(text);var textb=document.getElementById(textb);textb.value=text.value;document.getElementById('comment_id').value=comm_id;document.getElementById('type_flag').value=type_flag;e.style.visibility='';}
function div_invisible(id)
{var e=document.getElementById(id);e.style.visibility='hidden';}
function is_number_temp(field_name,s)
{if(field_name.value=="")
{var error="Cannot leave the "+s+" field blank";alert(error);return false;}
if(isNaN(field_name.value))
{var error=s+" field Should Be Numberic";alert(error);return false;}
return true;}
function div_invisible_tooltip(id,id1)
{var e=document.getElementById(id);e.style.visibility='hidden';}
function div_visible_tooltip(id,id1,m)
{var e=document.getElementById(id);var f=document.getElementById(id1);if(m.pageX!=null)
{e.style.left=m.pageX+5+"px";e.style.top=m.pageY+5+"px";}
else
{var xcoord=m.clientX;var ycoord=m.clientY;if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
{xcoord+=document.body.scrollLeft;ycoord+=document.body.scrollTop;}
else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
{xcoord+=document.documentElement.scrollLeft;ycoord+=document.documentElement.scrollTop;}
e.style.left=xcoord+5+"px";e.style.top=ycoord+5+"px";}
e.innerHTML=f.value;e.style.visibility='';e.style.zIndex=999;}
function func(frmElem,domain)
{var frm=document.formname;if(frmElem.value=="scat")
{if(domain=="WS1")
{var domainid=frm.domain
[frm.domain.selectedIndex].value;var domaintext=frm.domain
[frm.domain.selectedIndex].text;}
else
{domainid="";domaintext="";}
var catid=frm.category
[frm.category.selectedIndex].value;var cattext=frm.category
[frm.category.selectedIndex].text;var win=window.open("/Paper/My_papers/get_subcategory.php?did="+domainid+"&dtxt="+domaintext+"&catid="+catid+"&cattxt="+cattext,"win1","left=20,top=20,width=350,height=200");win.focus();}}
function funcnew(frmElem,domain)
{var frm=document.formname;if(frmElem=="scat")
{if(domain=="WS1")
{var domainid=frm.select_domain
[frm.select_domain.selectedIndex].value;var domaintext=frm.select_domain
[frm.select_domain.selectedIndex].text;}
else
{domainid="";domaintext="";}
var catid=frm.select_category
[frm.select_category.selectedIndex].value;var cattext=frm.select_category
[frm.select_category.selectedIndex].text;var win=window.open("/Paper/My_papers/get_subcategory.php?did="+domainid+"&dtxt="+domaintext+"&catid="+catid+"&cattxt="+cattext,"win1","left=20,top=20,width=350,height=200");win.focus();}}
function ajax_call()
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{document.getElementById('result').innerHTML=xmlhttp.responseText;window.location.reload();}}
xmlhttp.open("GET","edit_comment.php?comment_id="+document.getElementById('comment_id').value+"&comment_text="+document.getElementById('textb').value+"&type_flag="+document.getElementById('type_flag').value,true);xmlHttp.send(null);}
function disable_submit()
{document.formname.get_reg.disabled=true;}
function hideall(count)
{var i;for(i=0;i<count;i++)
{var divId='layer'+i;var div1Id='layer_hot'+i;var menu=document.getElementById(divId);var menu1=document.getElementById(div1Id);if(menu.style.visibility=='visible')
menu.style.visibility='hidden';if(menu1.style.visibility=='visible')
menu1.style.visibility='hidden';}}
function startTime(){if(timerOn==false){timerID=setTimeout('hideall(5)',timecount);timerOn=true;}}
function stopTime(){alert(hi);if(timerOn){clearTimeout(timerID);timerID=null;timerOn=false;}}
function validateReportPrice(price,errorDiv)
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{alert("Browser does not support HTTP Request");return;}
xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{document.getElementById(errorDiv).innerHTML=xmlHttp.responseText;}
else
{if(price!="")
{document.getElementById(errorDiv).innerHTML="<img src='/Images/ajax-loader1.gif' height='20' width='20'/>";}}}
xmlHttp.open("GET","validate_price.php?price="+price,true);xmlHttp.send(null);}<!--
function check_length(obj,limit,divID)
{var myDiv=document.getElementById(divID);maxLen=limit;if(obj.value.length>maxLen){var msg="You have reached your maximum limit of characters allowed";alert(msg);obj.value=obj.value.substring(0,maxLen);myDiv.innerHTML=maxLen-obj.value.length;}
else{myDiv.innerHTML=maxLen-obj.value.length;}}

//changed by rajesh, for issue 54, Dt. 12/10/2010 - start
function removeComment ()
{
	if(document.getElementById('background'))
	{
		var a=document.getElementById('background');
		document.body.removeChild(a);
	}

	if(document.getElementById('commentBox'))
	{
		var b=document.getElementById('commentBox');
		document.body.removeChild(b);
	}
	hideDialog();
}
function getComments(loginId,paperId,paperType,paperLink)
{
	var pageNum = currPageNum;
	var pageLink = paperJpegsPathHttp;
	var mylib = document.getElementById('myLibrary').innerHTML;
	var myPage = document.getElementById('myPageAsSlide').innerHTML;
	if (parent.document.getElementById('commentBox'))
	{
		var a = parent.document.getElementById('commentBox');
		parent.document.body.removeChild(a);
	}
	
	if (parent.document.getElementById('background'))
	{
		var a = parent.document.getElementById('background');
		parent.document.body.removeChild(a);
	}

	var commentBoxData = '<table width="100%"><tr><td align="left"><table width="100%"><tr><td colspan="2" align="left">'+mylib+'</td></tr><tr><td colspan="2" align="left"><a href="#" onclick=\'javascript:savePaperPage("'+loginId+'","'+paperId+'","'+paperType+'","'+pageNum+'","'+paperLink+'","'+pageLink+'");\'><b>Save this page</b></a></td></tr><tr><td colspan="2" align="left">'+myPage+'</td></tr><tr><td colspan="2">&nbsp;</td></tr></table></td><td valign="top" align="right"><img src="/Images/cancel.gif" onClick="removeComment()"></td></tr></table>';
	var height = "100px";

	//<img src="/Images/new.gif" border="0" alt="" />&nbsp;
	/*Added by Rajesh Reddy on 25-6-2010*/

	//alert(parent.document.documentElement.scrollHeight);
	/*if (type == 'usrEditFlag')
	{*/
		var bgheight = parent.document.documentElement.scrollHeight;
	/*}else
	{
		var bgheight = parent.window.screen.height;
	}*/
	/*end*/
	
	var background = parent.document.createElement('iframe');
	var divIdName = 'background';
	background.setAttribute('id',divIdName);
	background.style.width = parent.window.screen.width+"px";
	background.style.height = bgheight +"px";
	background.style.left = "0px";
	background.style.top = "0px";
	background.style.background = "black";
	background.style.opacity=".25";
	background.style.filter="alpha(opacity=25)";
	background.style.position ="absolute";
	background.style.zIndex ="10";
	background.style.visibility = "visible";
	parent.document.body.appendChild(background);

	var commentBox = parent.document.createElement('div');
	var divIdName = 'commentBox';
	commentBox.setAttribute('id',divIdName);
	commentBox.className="popWindow";
	//commentBox.style.left = (parent.document.body.clientWidth/2.5) + "px";
	//commentBox.style.top =  (parent.document.body.clientHeight/2) + "px";
	commentBox.style.left = "370px";
	commentBox.style.top =  "262px";
	commentBox.style.position ="absolute";
	commentBox.style.width = "200px";
	commentBox.style.height = height;
	//commentBox.style.padding = "25px 25px 25px 25px";
	commentBox.style.padding = "5px 5px 5px 5px";
	commentBox.innerHTML = commentBoxData;
	commentBox.style.zIndex ="200";
	commentBox.style.visibility = "visible";
	parent.document.body.appendChild(commentBox);

	//document.userOptions.done.focus();
}
//changed by rajesh, for issue 54, Dt. 12/10/2010 - end
/*Added by Rajesh Reddy for issue 401*/
function checkdelslide(field_name)
{
    var field_name;
    if(field_name.checked==false)
    {
            alert("Please select the checkbox to delete the Slide");
            return false;
    }else
    {
           return true;
    }
}
/*end*/
