function conf(action) {

if(!confirm('Are you sure you want to '+action+' selected item. Continue...?'))

return false;

}



function popup(url, wh, ww, sb)	{

	var mywindow = null;

	  if ( ( mywindow != null ) && !mywindow.closed )  {

		    mywindow.close();

	      }

		  mywindow = window.open(url,"nppopup",'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars='+sb+',resizable=no,height='+wh+',width='+ww+',left=100, top=100');

		}





function chatbox()	

{

chatwindow = window.open('http://shaikhportal.com/chat',"chatpop",'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,height=435,width=780,left=10, top=10');

}

		



function enablebutton(chkname, btnMain, btnMore, btnFeature)

{



var chkCount=0; 	

if(document[chkname.form.name].elements[chkname.name].length)

{

 for (var i = 0; i<document[chkname.form.name].elements[chkname.name].length; i++)

	{

	if (document[chkname.form.name].elements[chkname.name][i].checked)

	 chkCount=chkCount+1;     

	}

togglebuttons(chkCount, chkname, btnMain, btnMore, btnFeature);

}

else

{

	if(document[chkname.form.name].elements[chkname.name].checked)

		{ document[chkname.form.name].elements[btnMain.name].disabled=false; document[chkname.form.name].elements[btnMore.name].disabled=false; document[chkname.form.name].elements[btnFeature.name].disabled=false;}

		else

		{ document[chkname.form.name].elements[btnMain.name].disabled=true; document[chkname.form.name].elements[btnMore.name].disabled=true; document[chkname.form.name].elements[btnFeature.name].disabled=true;}

}

}		



function togglebuttons(valCheck , chkname, btnMain, btnMore, btnFeature)

{



switch (valCheck)

{

		case 1: document[chkname.form.name].elements[btnMain.name].disabled=false; document[chkname.form.name].elements[btnMore.name].disabled=true; document[chkname.form.name].elements[btnFeature.name].disabled=true;

		break;

		case 4:  document[chkname.form.name].elements[btnMain.name].disabled=true; document[chkname.form.name].elements[btnMore.name].disabled=false; document[chkname.form.name].elements[btnFeature.name].disabled=true;

		break;

		case 2:  document[chkname.form.name].elements[btnMain.name].disabled=true; document[chkname.form.name].elements[btnMore.name].disabled=true; document[chkname.form.name].elements[btnFeature.name].disabled=false;

		break;

		case 0:  document[chkname.form.name].elements[btnMain.name].disabled=true; document[chkname.form.name].elements[btnMore.name].disabled=true; document[chkname.form.name].elements[btnFeature.name].disabled=true;

		break;

		default:  document[chkname.form.name].elements[btnMain.name].disabled=true; document[chkname.form.name].elements[btnMore.name].disabled=true; document[chkname.form.name].elements[btnFeature.name].disabled=true;

		break;

}

}







function searchColor(obj)

{

document.getElementById('website').bgColor='#003399';

document.getElementById('dir').bgColor='#003399';

document.getElementById('people').bgColor='#003399';

document.getElementById('quotes').bgColor='#003399';

obj.bgColor='#669900';



//obj.style.textDecoration='underline';

document.getElementById('search').innerHTML=obj.innerHTML;

}



function uu(obj)

{

document.getElementById('searchform').action=obj.href;

document.getElementById('s').value='a';

document.getElementById('k').focus();

}



function bookIt(argVal)

{

var bookData = new Array();

bookData = argVal.split("|");

if (document.all)

window.external.AddFavorite(bookData[0], bookData[1]);

else

alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");

}



function vsendemail(sendform)

{

if(sendform.toemail.value==''||sendform.email.value==''||sendform.name.value=='')

{

alert("Check required fields!");

return false;

}



}



function vguestbook(gbookform)

{

if(gbookform.name.value==''||gbookform.comments.value=='')

{

alert("Check required fields!");

return false;

}

}





var isNetscape = (navigator.appName.indexOf('Netscape') != -1);

function calcHeight()

{

try{	

var oBody	=	ifrm.document.body;

var oFrame	=	document.all("ifrm");

if (isNetscape) {

the_height = document.getElementById('the_iframe').contentDocument.body.scrollHeight;

document.getElementById('the_iframe').style.height = the_height

} else {

oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);

}

}

//An error is raised if the IFrame domain != its container's domain

catch(e)

{

window.status =	'Error: ' + e.number + '; ' + e.description;

}

}





function updatephoto(imagesrc)

{

opener.document.images.photoimage.src= "http://"+ window.location.hostname+"/media/epals/"+imagesrc;

opener.profileform.photoimage.value= "/media/epals/"+imagesrc;

window.close;

}

//Save textarea current cursor position
function storeCaret (textEl) {
       if (textEl.createTextRange) 
         textEl.caretPos = document.selection.createRange().duplicate();
     }
//insert at current cursor position
function insertAtCaret (textEl, text) {
       if (textEl.createTextRange && textEl.caretPos) {
         var caretPos = textEl.caretPos;
         caretPos.text =
           caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
             text + ' ' : text;
       }
       else
         textEl.value  = text;
     }

function forumattachment(imagesrc, description)

{

//opener.forumform.attachment.value= opener.forumform.attachment.value + " #!# " + imagesrc;
//opener.forumform.description.value= opener.forumform.description.value  + " #!# " +   imagesrc;

var toInsert = "\r[attachment]" +  imagesrc+ "[/attachment][description]"+ description +"[/description]\r";
insertAtCaret(opener.forumform.body, toInsert)

//opener.forumform.body.value= opener.forumform.body.value 

window.close;

}

function videoattachment()
{
var answer = prompt ("Enter Video Embed Code:","");
document.forumform.attachment.value= answer;
document.forumform.description.value= answer;
window.close;
}


function GetMritemsIndex(str)

{

	var index = str.indexOf("media");

	if (index == -1)

		index = str.indexOf("epals");

	return str.slice(index,str.length);

}





///////  Image script //////



function DoneNowPic(what, type) {

var filename = "";

var PicIndex = what.lastIndexOf('.', what.length - 1);

var PicFileExtension = what.substr(PicIndex + 1).toLowerCase();

if ((PicFileExtension != 'jpg') && (PicFileExtension != 'gif') && (PicFileExtension != 'jpeg') && (PicFileExtension != 'bmp') && (PicFileExtension != 'png') && (PicFileExtension != 'jpe')) {



document.images.theimage.src="noimage.jpg"

return false;

} else {

filename = "file:///" + document.MyForm.image.value;

document.images.theimage.src=filename

}

}



function ShowProgress()

{

  strAppVersion = navigator.appVersion;

  if (document.MyForm.FILE.value != "" || document.MyForm.FILE2.value != "" || document.MyForm.image.value != "")

  {

    if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)

    {

      winstyle = "dialogWidth=375px; dialogHeight:130px; center:yes";

      window.showModelessDialog('&b=IE',null,winstyle);

    }

    else

    {

      window.open('&b=NN','','width=370,height=115', true);

    }

  }

  return true;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_validateForm() { //v4.0

  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);

    if (val) { nm=val.name; if ((val=val.value)!="") {

      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

      } else if (test!='R') { num = parseFloat(val);

        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

          min=test.substring(8,p); max=test.substring(p+1);

          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

  } if (errors) alert('The following error(s) occurred:\n'+errors);

  document.MM_returnValue = (errors == '');

}



function tmt_checkImgObj(){//v2.0

	var errorMsg="";

	if(this.maxS!=""&&this.fileSize/1000>this.maxS){

		errorMsg+="Image is too large. Maximum allowed size is: "+this.maxS+" kilobytes \n";}

	if(this.minS!=""&&this.fileSize/1000<this.minS){

		errorMsg+="Minimum size for images is: "+this.minS+" kilobytes \n";}

	if(this.maxW!=""&&this.width>this.maxW){

		errorMsg+="Maximum width allowed for images is: "+this.maxW+" pixels \n";}

	if(this.minW!=""&&this.width<this.minW){

		errorMsg+="Minimum width allowed for images is: "+this.minW+" pixels \n";}

	if(this.maxH!=""&&this.height>this.maxH){

		errorMsg+="Maximum height allowed for images is: "+this.maxH+" pixels \n";}	

	if(this.minH!=""&&this.height<this.minH){

		errorMsg+="Minimum height allowed for images is: "+this.minH+" pixels \n";}	

	if(errorMsg==""){

		if(this.fW){var fW=MM_findObj(this.fW);if(fW){fW.value=this.width;}}

		if(this.fH){var fH=MM_findObj(this.fH);if(fH){fH.value=this.height;}}}

		else{alert(errorMsg);}document.MM_returnValue=(errorMsg=="");

}



function tmt_createImgObj(imgURL,loadHandler,minW,maxW,minH,maxH,minS,maxS,fW,fH){//v2.0

	document.MM_returnValue=false; var img=new Image();img.minW=minW;img.maxW=maxW;img.minH=minH;img.maxH=maxH;

	img.fW=fW;img.fH=fH;img.minS=minS;img.maxS=maxS;img.onload=loadHandler;img.src=imgURL;

}



function tmt_CheckImg(formElement,minW,maxW,minH,maxH,minS,maxS,mime,fW,fH){//v2.1

	document.MM_returnValue=true;if(document.getElementById){var obj=MM_findObj(formElement);

	var f=obj.form.name;if(obj&&f){var exRex=new RegExp("\\.("+mime+")$","i");

	//var noWhiteRex=/\\[\w_]*(\s)*\.(\w{3})$/i;if(exRex.test(obj.value)&&noWhiteRex.test(obj.value)){

	var noWhiteRex=/\\[\w_]*(\s)*\.(\w{3})$/i;if(exRex.test(obj.value)){

	var imgURL="file:///"+obj.value;tmt_createImgObj(imgURL,tmt_checkImgObj,minW,maxW,minH,maxH,minS,maxS,fW,fH);

	eval("setTimeout(\"if(document.MM_returnValue){document."+f+".submit()}\",300)");}

	else{document.MM_returnValue=false;alert("File field cannot be empty. Only "+mime+" files are allowed, no whitespaces inside names and the image dimensions should be as stated");

	obj.focus();obj.select();}}}

}

