// AJB - function for delaying a menu hide
var ajbtimeout = 0;
function delayhide(t){
    if(ajbtimeout > 0){
		setTimeout("dodelayhide('"+t+"\')", 1000);
	}
}

function dodelayhide(t){
	hide(t);
	ajbtimeout = 0;
}



// Code for limiting length of a textarea
function textareaMaxLength(field,maxChars){
   if(field.value.length >= maxChars) {
//       event.returnValue=false;
       return false;
   }
}  
function textareamaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
	if (obj.getAttribute && obj.value.length>mlength){
		obj.value=obj.value.substring(0,mlength);
	}
}

function textareaMaxLengthPaste(field,maxChars){
//   event.returnValue=false;
   if((field.value.length +  window.clipboardData.getData("Text").length) > maxChars){
      return false;
   }
 //  event.returnValue=true;
}


function expandArticle(expand) {
    if (expand) {
        var lES=document.getElementById("article_end").style;
        lES.display="block";
        lES=document.getElementById("see_all_link").style;
        lES.display="none";
        lES=document.getElementById("shorten_link").style;
        lES.display="block";
    } else {
        var lES=document.getElementById("article_end").style;
        lES.display="none";
        lES=document.getElementById("see_all_link").style;
        lES.display="block";
        lES=document.getElementById("shorten_link").style;
        lES.display="none";
    }
}

// Code for rotating pro tips
var tip=0;
var tiptid;
var bigtip=1;
function rotatetips(){
    tip++;
    var elem=document.getElementById("tip"+tip);
    if(elem == undefined){
        tip=0;
    } else {
        if(tip > bigtip){
            bigtip = tip;
        }
        for(e=1;e<=bigtip;e++){
            var lES=document.getElementById("tip"+e).style;
           	lES.display="none";
		}
        var lES=elem.style;
       	lES.display="block";
    }
	//    clearInterval(tiptid); 
}
tiptid = setInterval('rotatetips()',10000);


function resetForm (formName) {
	fName = (formName == null) ? 0 : formName;
	if (document.forms[fName] == null) {
		alert('Error while trying to reset the FORM.\n\nPlease contact website administrator.\nThank you!');
	}
	else if(confirm('Are you sure that you want to RESET form?')) document.forms[fName].reset();
}

function ext (url) {
	URL = "http://" + url;
	if (typeof(suntgayExternalWin) == "undefined") suntgayExternalWin = window.open (URL, "suntgayExternalWindow");
	else suntgayExternalWin.location.url = URL;
	suntgayExternalWin.focus();
	/*a.document.open();
	a.document.write("<html><FRAMESET rows='50, *' frameborder='0'><FRAME src='http://www.suntgay.ro/inapoi'><FRAME src='" + url + "'></FRAMESET></html>");
	a.document.close();*/
}

function inapoi () {
	top.opener.focus();
	top.close();
}

function nextBillboard() {
	//init
	cookieName = 'PayICanBillboard';
	maxPhotos = 4;
	expirationDays = '2';
	cookieUrl = '/payican/';
	theDomain = 'design4.transformagency.biz';

	//exec
	cookieVal = getCookie(cookieName);
	if (cookieVal == null) setCookie(cookieName, cookieUrl, expirationDays, '', theDomain);
	newPhotoID = parseInt(cookieVal) + 1;
	newPhotoID = ( newPhotoID <= maxPhotos ) ? newPhotoID : 1;
	setCookie(cookieName, cookieUrl, expirationDays, newPhotoID, theDomain);
	document.write('<img src="_include/gui/billboards/' + newPhotoID + '.jpg" width="900" height="225" alt="Start Accepting Credit Cards" />');
}


function nextHeader() {
	//init
	cookieName = 'PayICanHeader';
	maxPhotos = 6;
	expirationDays = '2';
	cookieUrl = '/payican/';
	theDomain = 'design4.transformagency.biz';
	root = "http://design4.transformagency.biz/payican/";

	//exec
	cookieVal = getCookie(cookieName);
	if (cookieVal == null) { setCookie(cookieName, cookieUrl, expirationDays, '', theDomain);}
	newPhotoID = parseInt(cookieVal) + 1;
	newPhotoID = ( newPhotoID <= maxPhotos ) ? newPhotoID : 1;
	setCookie(cookieName, cookieUrl, expirationDays, newPhotoID, theDomain);

	count = 0;
	str = document.URL.substring(root.length, document.URL.length);
	delimiter = "/";
	pos = str.indexOf(delimiter);
	while ( pos != -1 ) {
	   count++;
	   pos = str.indexOf(delimiter,pos+1);
	}
	relativeToRoot ="";
	for ( i = 1; i <= count; i++) relativeToRoot += "../";
	document.write('<img src="' + relativeToRoot + '_include/gui/headers/' + newPhotoID + '.jpg" width="900" height="126" alt="Start Accepting Credit Cards" />');
}

function toggleMe(a){
	var e=document.getElementById(a);
	if(!e)return true;
	if(e.style.display=="none"){
		e.style.display=displayType();
	} else {
		e.style.display="none";
	}
	return true;
}

function displayType() {
var isDOM=document.getElementById?1:0,
 isIE=document.all?1:0,
 isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,
 isOp=self.opera?1:0,
 isDyn=isDOM||isIE||isNS4;
	if (isIE) {
//		alert('It is IE');
		return 'block';
	} else {
//		alert('It is FF');
		return 'table-row';
	}
}

function show(id) {
	if (document.getElementById(id)) { 
		obj = document.getElementById(id); 
		obj.style.display = "block"; 
	}
}

function hide(id) {
	if (document.getElementById(id)) { 
		obj = document.getElementById(id); 
		obj.style.display = "none"; 
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

