		

						
						
						function txtLim(maxlimit, myelement, warning) 
{
	document.getElementById(myelement).value = document.getElementById(myelement).value.substring(0, maxlimit);
	var x = document.getElementById(myelement).value.length;
	var y = maxlimit - x;	
	document.getElementById(warning).innerHTML = "You have <b>" + y + "</b> charactors left";	
}

function countcbox(maxcounter)
{

var t = 1;
count = 0; 
str = ''; 

    for(x=0; x<document.form1.elements["cat[]"].length; x++){ 
        if(document.form1.elements["cat[]"][x].checked==true){ 
            str += document.form1.elements["cat[]"][x].value + ','; 
            count++; 
        } 
    } 
  
  t = maxcounter - count
	

	if (t < 0)
		{
			document.getElementById("chkbxCount").innerHTML = "<b>WARNING:</b> You have used <b>" + count + "</b> catagories, Max is 10.";	
		}
	else
		{
			document.getElementById("chkbxCount").innerHTML = "You have a up to <b>" + t + "</b> catagories left";	
		
		}
}



function openVoteBox()
{
	document.getElementById('voteBoxQ').innerHTML = "<a href=\"#\" onclick=\"javascript:closeVoteBox();\"><b>Close and ignore</b></a>";
	document.getElementById('voteBoxA').innerHTML = "<input type=\"hidden\" name=\"dovote\" value=\"yes\" /><div style=\"padding:25px;\"><table cellpadding=\"3\" cellspacing=\"0\" align=\"center\" width=\"100%\"><tr><td class=\"detail2\"> Question </td><td class=\"detail2\"><input type=\"text\" name=\"qQuestion\" size=\"60\" value=\"\" /></td></tr><tr><td colspan=\"2\"><b>Any possible awnsers left blank will be ignored, just write in each box each possible responce.</b></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr><tr><td class=\"detail1\" valign=\"top\">Awnser</td><td class=\"detail1\" valign=\"top\"><input type=\"text\" name=\"qAwnser[]\" size=\"60\" value=\"\" /></td></tr></table></div>";
}
function closeVoteBox()
{
	document.getElementById('voteBoxQ').innerHTML = "<a href=\"#\" onclick=\"javascript:openVoteBox();\">Open vote box</a>";
	document.getElementById('voteBoxA').innerHTML = "";
}

function MakeCurrency()
{
		var x;
		var url;
		var TheNumber;
		
		TheNumber = document.forms[0].elements["amount"].value;
		
		if (document.forms[0].elements["type"].value == "1") 
				{ 
					x = "&from=GBP&to=TRY&Calculate=Convert"; 
				}
		else 
				{
					x = "&from=TRY&to=GBP&Calculate=Convert";
				}
		
		url = "http://www.gocurrency.com/v2/dorate.php?inV=" + TheNumber + x;
		
	//	alert(url);
		
		document.getElementById('cur').innerHTML = "<iframe  src=\"" + url + "\" width=\"700\" height=\"500\"><a href=\"" + url + "\" target=\"_blank\">Click here to view</a></iframe><br/>" + url;
		
}

function SelectPicBox(boxer)
{ 
	// Class of Box
	if (document.getElementById('PBox' + boxer).className == 'picbox_off')
	{ document.getElementById('PBox' + boxer).className = "picbox_on";}
	else {document.getElementById('PBox' + boxer ).className = "picbox_off";}
	// Checkbox
	if (document.getElementById('PicSelect' + boxer).checked  == true)
	{ document.getElementById('PicSelect' + boxer).checked  = false;}
	else {document.getElementById('PicSelect' + boxer).checked  = true;}
}


function openMsgPicBox(mode) {
				document.getElementById('repPicBox').innerHTML = "<img src=\"/site/pic/loading.gif\" />";	
				document.getElementById('repPicCloser').innerHTML = "";
				
			    http.open('get', '/site/pictures.msger.php?mode=' + mode + '&rnd='+Math.random ( ));
   				http.onreadystatechange = MSGgrabPictures;
    			http.send(null);
	
}

function MSGgrabPictures() {
    if(http.readyState == 4)
	{
   		document.getElementById('repPicBox').innerHTML = http.responseText;
	}
}

function AddToMsg(title, username, filepath, id, mode) {
	var x;

			x = '<br/><a href="/site/gal.view.pic.php?pic=' + id + '" target="_blank"> "<b>' + title + '</b>" by "<b>' + username + '</b>"<br><img src="' + filepath + '" title="Click to open ' + title + '" border="0" /><br/>[Open Picture]</a><br/>\n';
	//	x = "<b>some text</b>";
		
	tinyMCE.execInstanceCommand('GetTheMessage','mceInsertRawHTML',true,x);
	return false;
	
//	alert(mode);
//	document.getElementById('GetTheMessage').value = x;
	// alert(x);
	
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function GrabThePics()
{
	var selValue = document.getElementById('CatSelect').value;
	// do we do it?
	if (selValue == "na") { document.getElementById('intPicBox').innerHTML = "<h1>Please Select a gallary</h1>";}
	else{ 
			document.getElementById('intPicBox').innerHTML = "<img src=\"/site/pic/loading.gif\" />";	
				
			    http.open('get', '/site/pictures.org.internal.php?cat='+selValue+'&rnd='+Math.random ( ));
   				http.onreadystatechange = grabPictures;
    			http.send(null);

	}	// end 'do we do it'
} //end function

function grabPictures() {
    if(http.readyState == 4)
	{
   		document.getElementById('intPicBox').innerHTML = http.responseText;
	}
}


function SelectPicEditBox(id)
{
	// do we do it?
	if (document.getElementById('PBox' + id).className == 'picbox_off')
	{ document.getElementById('PBox' + id).className = "picbox_on";}
	else {document.getElementById('PBox' + id ).className = "picbox_off";}
	
	
				document.getElementById('EditBox').innerHTML = "<img src=\"/site/pic/loading.gif\" />";	
			    http.open('get', '/site/pictures.mod.internal.php?pic='+id+'&rnd='+ Math.random ( ));
   				http.onreadystatechange = showEditBox;
    			http.send(null);

} //end function


function showEditBox() 
{
   if(http.readyState == 4) { 
   	document.getElementById('EditBox').innerHTML = http.responseText;
	window.location = '#anc_edit';
	 }
}


		
		function MM_openBrWindow(theURL,winName,features) { 
		  window.open(theURL,winName,features);
		}

		function opencloser(diver){
			if (document.getElementById(diver).style.display == 'none'){ document.getElementById(diver).style.display = 'inline';}
			else {document.getElementById(diver).style.display = 'none';}
		}

		function gotourl(url) {window.location = url;}

		function MM_swapImgRestore() { 
		  var i,x,a=document.MM_sr; 
		  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
		
		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_swapImage() { //v3.0
		  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}