// JavaScript Document cscripts.js

/**
 *
 *	General Bowser Deductions and General Utility Functions
 *=========================================================*/

var SiteTitle = 'HTmate.com';
var detect = navigator.userAgent.toLowerCase();// alert(detect);
var OS,browser,version,total,thestring;
if (_checkIt('konqueror')) { 
	browser = "Konqueror"; OS = "Linux"; 
} else if (_checkIt('safari')) 
	browser = "Safari" 
		else if (_checkIt('opera')) 
		browser = "Opera" 
			else if (_checkIt('msie')) 
			browser = "IE" 
				else if (!_checkIt('compatible')) { 
					browser = "Netscape Navigator" 
					version = detect.charAt(8); 
				} else browser = "Unknown"; 

if (!version) version = detect.charAt(place + thestring.length); 
if (!OS) { 
	if (_checkIt('linux')) OS = "Linux"; 
	else if (_checkIt('x11')) OS = "Unix"; 
		else if (_checkIt('mac')) OS = "Mac" 
			else if (_checkIt('win')) OS = "Windows" 
				else OS = "Unknown"; 
} 

function _checkIt(string) { 
	place = detect.indexOf(string) + 1;
	thestring = string; 
	return place; 
}// EOF _checkIt()

//------------------------

function ChangePropertyById(objId, propName, propValue) { 
	var obj = getObject(objId); 
	if (obj && (propName.indexOf("style.")==-1 || obj.style)) { 
		if (propValue == true || propValue == false) {
			//alert("obj."+propName+"="+propValue);
			eval("obj."+propName+"="+propValue); 
		}
		else {
			//alert("obj."+propName+"="+propValue);
			eval("obj."+propName+"='"+propValue+"'"); 
		}
	} 
}// EOF ChangePropertyById() 


function getObject(id) { 
	if (document.all) { 
		return document.all[id]; 
	} else { 
		return document.getElementById(id); 
	} 
}// EOF getObject()

var copytoclip=1
function HighlightAll(theField) {
	var tempval=eval("document."+theField)
	tempval.focus()
	tempval.select()
	if (document.all&&copytoclip==1){
		therange=tempval.createTextRange()
		therange.execCommand("Copy")
		window.status="Code copied to clipboard!"
		setTimeout("window.status=''",1800)
	}
alert("Code Copied Successfully!");
}//END OF HighLightAll

function CopyAll(theField) { 
	var temp=eval("document."+theField);
	temp.focus();
	temp.select();
	theRange=temp.createTextRange();
	theRange.execCommand("Copy");
}// EOF CopyAll()


function OpenWin(url,name) 	{
	name = name?name:SiteTitle;
	window.open(url,name,"scrollbars=1,width=700,height=900");
	return;
}// EOF openWin()

//-----------------------------------

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  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];}
}

//----------------------------------------------

function ToggleTab(id, show, total) {
	if (show && total) {
		var label = id+show;
		var now = document.getElementById(label);
		
		var tlabel = '';
		for(var i=1; i<=total; i++) {
			tlabel = id+i;
			if (show != i)
				document.getElementById(tlabel).style.display = 'none';
		}//EOF for
		
		now.style.display = 'block';
	}//EOF if
}// EOF ToggleTab()


	function Openbd() {
		url = (browser=='IE'?'http://www.genmyspace.com/banner/':'http://www.genmyspace.com/banner/') + 'bdesign.php';// alert(url);
		r = window.open(url,'BannerDesigner',"scrollbars=1,width=700,height=900");
	}// EOF Openbd()


//==================================================================================================================================

function ImgfCode() {
	var fimg = 'img { filter: '+document.getElementById('nonlinkedfilter').value + ' }';
	var flink = 'a:link img { filter: '+document.getElementById('linkedfilter').value + ' }';
	var fhover = 'a:hover img { filter: '+document.getElementById('rolloverfilter').value + ' }';
	document.frmImgFilter.filterCode.value = '<style type="text/css">\n'+fimg+'\n'+flink+'\n'+fhover+'\n</style>'; 
}// EOF ImgfCode() 

//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Marquee Generator
 */
 
var defaultMarQtext = SiteTitle+' is Awesome!'; 
 
function CheckBorder(borderPropName) { 
	if (borderPropName != "width" && document.frmMarquee.borderwidth.value == "") { 
		document.frmMarquee.borderwidth.options[3].selected = true; 
		ChangePropertyById('prevumarquee','style.borderWidth', document.frmMarquee.borderwidth.value); 
	} 
	
	if (borderPropName != "style" && document.frmMarquee.borderstyle.value == "") { 
		document.frmMarquee.borderstyle.options[2].selected = true; 
		ChangePropertyById('prevumarquee','style.borderStyle', document.frmMarquee.borderstyle.value); 
	} 
	
	if (document.frmMarquee.bcolor.value == "") { 
		document.frmMarquee.bcolor.value = "#000000"; 
		ChangePropertyById('prevumarquee','style.borderColor', document.frmMarquee.bcolor.value); 
	} 
}// EOF CheckBorder()

function MarqueeCoder() {
	code = '<MARQUEE style=\"';
	if (document.frmMarquee.bgcolor.value != "") { 
		code += 'background-color:' + document.frmMarquee.bgcolor.value + '; '; 
	}
	if (document.frmMarquee.borderwidth.value != "" && document.frmMarquee.borderstyle.value != "" && document.frmMarquee.bcolor.value != "") { code += 'border: ' + document.frmMarquee.borderwidth.value + ' ' + document.frmMarquee.borderstyle.value + ' ' + document.frmMarquee.bcolor.value + "; "; }
	if (document.frmMarquee.textcolor.value != "") { code += 'color:' + document.frmMarquee.textcolor.value + '; '; }
	if (document.frmMarquee.textfont.value != "") { code += 'font-family:' + document.frmMarquee.textfont.value + '; '; }
	if (document.frmMarquee.textsize.value != "") { code += 'font-size:' + document.frmMarquee.textsize.value + '; '; }
	if (document.frmMarquee.mwidth.value != "") { code += 'width:' + document.frmMarquee.mwidth.value + 'px; '; }
	if (document.frmMarquee.mheight.value != "") { code += 'height:' + document.frmMarquee.mheight.value + 'px; '; }	
	code += '\" ';
	if (document.frmMarquee.direction.value != "") { code += 'direction=\"' + document.frmMarquee.direction.value + '\" '; }
	if (document.frmMarquee.behavior.value != "") { code += 'behavior=\"' + document.frmMarquee.behavior.value + '\" '; }
	if (document.frmMarquee.scrollamount.value != "") { code += 'scrollamount=\"' + document.frmMarquee.scrollamount.value + '\" '; }
	code += '>';
	if (document.getElementById('prevumarquee').innerHTML != "") { code += document.getElementById('prevumarquee').innerHTML; }
	code += '</MARQUEE>';
	for(var x = 0; x < 4; x++) 	{
		code = code.replace(/#/, ""); 
	}
	getObject('marQcode1').value = code;	
}// EOF MarqueeCoder()

function InsertText() {// alert(defaultMarQtext);
	var addtext = prompt('Please type the text you wish to add','');
	var prevumarquee = getObject('prevumarquee');
	if (prevumarquee.innerHTML == defaultMarQtext && addtext!=null) { 
		prevumarquee.innerHTML = ''; 
	} 
	if (addtext!=null) prevumarquee.innerHTML += ' ' + addtext; 

	MarqueeCoder(); 
}// EOF InsertText 


function InsertImage() { 
	var addimage = prompt('Please type the full URL to the image you wish to add','');
	var prevumarquee = getObject('prevumarquee');
	if (prevumarquee.innerHTML == defaultMarQtext && addimage!=null) { 
		prevumarquee.innerHTML = ''; 
	} 
	if (addimage!=null) prevumarquee.innerHTML += '' + '<img src="'+addimage+'">'; 

	MarqueeCoder(); 
}// EOF InsertImage  


function ResetMarquee() { 
	var prevumarquee = getObject('prevumarquee');
	if (prevumarquee.innerHTML != '') { 
		prevumarquee.innerHTML = defaultMarQtext;
	} 

	MarqueeCoder(); 
}// EOF ResetMarquee() 
//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Flash Image Gallery Generator
 */

var _nofClones = 0;

function CloneNinsert() {
	var iurls = getObject('iurls');
	var inners = iurls.cloneNode(true);
		inners.id = 'iurls' + ++_nofClones;
	aa = getObject('bin').insertBefore(inners, getObject('pluz'));
}// EOF CloneNinsert()

//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Scrolling Generator
 */

function ScrollCoder()
{
	
	codescroll = '<div style=\"';
	if (document.frmScroll.sbwidth.value != "")	{ codescroll += 'width:' + document.frmScroll.sbwidth.value + 'px; '; }
	if (document.frmScroll.sbheight.value != ""){ codescroll += 'height:' + document.frmScroll.sbheight.value + 'px; '; }
	if (document.frmScroll.bgcolor.value != "") { codescroll += 'background-color:' + document.frmScroll.bgcolor.value + '; '; }
	if (document.frmScroll.textcolor.value != ""){ codescroll += 'color:' + document.frmScroll.textcolor.value + '; '; 	}
	if (document.frmScroll.textfont.value != "") {codescroll += 'font-family:' + document.frmScroll.textfont.value + '; '; 	}
	if (document.frmScroll.textsize.value != "") {codescroll += 'font-size:' + document.frmScroll.textsize.value + '; '; }
	if(document.frmScroll.chkbold.checked) {	codescroll += 'font-weight:' + 'bold; '; }
	if(document.frmScroll.chkitalic.checked){codescroll += 'font-style:' + 'italic; '; }
	if (document.frmScroll.textalign.value != ""){ codescroll += 'text-align:' + document.frmScroll.textalign.value + '; ';	}
	if (document.frmScroll.borderwidth.value != "" && document.frmScroll.borderstyle.value != "" && document.frmScroll.bcolor.value != "")
	{ 
		codescroll += 'border: ' + document.frmScroll.borderwidth.value + ' ' + document.frmScroll.borderstyle.value + ' ' + document.frmScroll.bcolor.value + "; ";
	}
	codescroll += 'overflow: auto; padding: 4px;';
	codescroll += '">';
	if (document.frmScroll.scrolltext.value != ""){codescroll +=document.frmScroll.scrolltext.value;}
	if (document.getElementById('scrollgen').innerHTML != "") { codescroll += document.getElementById('scrollgen').innerHTML; }
	codescroll += '</div>';
	document.getElementById('ScrollCode').value = codescroll;	
}// EOF ScrollCoder()


//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Border
 */
function CheckBorderGen(borderPropName,frmName,id) { 
	if (borderPropName != "width" && document.frmName.borderwidth.value == "") { 
		document.frmName.borderwidth.options[3].selected = true; 
		ChangePropertyById('id','style.borderWidth', document.frmName.borderwidth.value); 
	} 
	
	if (borderPropName != "style" && document.frmName.borderstyle.value == "") { 
		document.frmName.borderstyle.options[2].selected = true; 
		ChangePropertyById('id','style.borderStyle', document.frmName.borderstyle.value); 
	} 
	
	if (document.frmName.bcolor.value == "") { 
		document.frmName.bcolor.value = "#000000"; 
		ChangePropertyById('id','style.borderColor', document.frmName.bcolor.value); 
	} 
}// EOF CheckBorderGen()

//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Scrolling Generator
 */

function CommentCoder()
{
	codecomment = '<form method="post" action="http://comments.myspace.com/index.cfm?fuseaction=user.ConfirmComment"><input name="friendID" ';
	if (document.frmCommentBox.fid.value != "") 
	{
		codecomment += 'value="' + document.frmCommentBox.fid.value+'"';  
	}
	else
	{
		codecomment += 'value=""';
	}
	codecomment += ' type="hidden">';
	codecomment += '<textarea name="f_comments"';
	if (document.frmCommentBox.cbsize.value == "esmall")
	{
		codecomment += 'style="width: 100px; height: 50px;';
	}
	else if(document.frmCommentBox.cbsize.value == "small")
	{
		codecomment += 'style="width: 150px; height: 75px;';
	}
	else if(document.frmCommentBox.cbsize.value == "medium")
	{
		codecomment += 'style="width: 200px; height: 100px;';	
	}
	else if(document.frmCommentBox.cbsize.value == "large")
	{
		codecomment += 'style="width: 225px; height: 125px;';
	}
	else if(document.frmCommentBox.cbsize.value == "elarge")
	{
		codecomment += 'style="width: 250px; height: 150px;';
	}
	if (document.frmCommentBox.bgcolor.value != "") { codecomment += 'background-color:' + document.frmCommentBox.bgcolor.value + '; '; }
	if (document.frmCommentBox.textcolor.value != ""){ codecomment += 'color:' + document.frmCommentBox.textcolor.value + '; '; 	}
	if (document.frmCommentBox.textfont.value != "") {codecomment += 'font-family:' + document.frmCommentBox.textfont.value + '; '; 	}
	if (document.frmCommentBox.textBold.checked) code += "font-weight: bold; ";
	if (document.frmCommentBox.textItalic.checked) code += "font-style: italic; ";
	if (document.frmCommentBox.textsize.value != "") {codecomment += 'font-size:' + document.frmCommentBox.textsize.value + '; '; }
	if (document.frmCommentBox.borderwidth.value != "" && document.frmCommentBox.borderstyle.value != "" && document.frmCommentBox.bcolor.value != "")
	{ 
		codecomment += 'border: ' + document.frmCommentBox.borderwidth.value + ' ' + document.frmCommentBox.borderstyle.value + ' ' + document.frmCommentBox.bcolor.value + "; ";
	}
	
	codecomment += '">';
	if (document.getElementById('previewsubmit').innerHTML != "") { codecomment += document.getElementById('previewsubmit').innerHTML; }
	codecomment += '</textarea><br /><input type="submit"';
	if (document.frmCommentBox.subttext.value != "")
	{
		codecomment +='value=' + document.frmCommentBox.subttext.value +' /></form>';
	}
	else
	{
		codecomment +='value="" /></form>';
	}
	
	document.getElementById('CommentCode').value = codecomment;	
}// EOF CommentCoder()



//----------------------------------------------------------------------------------------------------------------------------------
/**
 * Script for Comment Border
 */
function CheckBorderComment(borderPropName) { 

	
	if (borderPropName != "width" && document.frmCommentBox.borderwidth.value == "") { 
		document.frmCommentBox.borderwidth.options[3].selected = true; 
		ChangePropertyById('commentboxpreview','style.borderWidth', document.frmCommentBox.borderwidth.value); 
	} 
	
	if (borderPropName != "style" && document.frmCommentBox.borderstyle.value == "") { 
		document.frmCommentBox.borderstyle.options[2].selected = true; 
		ChangePropertyById('commentboxpreview','style.borderStyle', document.frmCommentBox.borderstyle.value); 
	} 
	
	if (document.frmCommentBox.bcolor.value == "") { 
		document.frmCommentBox.bcolor.value = "#000000"; 
		ChangePropertyById('commentboxpreview','style.borderColor', document.frmCommentBox.bcolor.value); 
	} 
}// EOF CheckBorderComment()


function ChangeSize(commentsize)
{
	
	if(commentsize=="esmall")
	{
		
		getObject('commentboxpreview').style.width="100px";
		getObject('commentboxpreview').style.height="50px";

	}
	else if(commentsize=="small")
	{
		
		getObject('commentboxpreview').style.width="150px";
		getObject('commentboxpreview').style.height="75px";
	}
	else if(commentsize=="medium")
	{
		
		getObject('commentboxpreview').style.width="200px";
		getObject('commentboxpreview').style.height="100px";
	}
	else if(commentsize=="large")
	{
		
		getObject('commentboxpreview').style.width="225px";
		getObject('commentboxpreview').style.height="125px";
	}
	else if(commentsize=="elarge")
	{
		
		getObject('commentboxpreview').style.width="250px";
		getObject('commentboxpreview').style.height="150px";
	}
	
}




//==================================================================================================================================
function NewPage(url, width, height) {
  	var nwindow = window.open(url, 'Help', 'width='+width+',height='+height+',top=0,left=0,scrollbars=no,menubar=no,resizeable=yes');
}// EOF NewPage()
  
function FidHelp()  {
    var help_url = 'http://www.pimptags.com/myspace/help/friend-id'; //"http://www.pimptags.com/" + section + "/help/" + topic;
  	var help_width = 660;
	var help_height = 500;
	
  	NewPage(help_url, help_width, help_height);
}// EOF FidHelp()
//==================================================================================================================================