﻿function flashEmbed(swfFileName, height, width) {
    
    AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', width,
		'height', height,
		'src', swfFileName,
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'swfFileName',
		'bgcolor', '#ffffff',
		'name', swfFileName,
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess', 'sameDomain',
		'movie', swfFileName,
		'textAdd', 'texti1',
		'salign', ''
			); //end AC code
	var embeded;
	embeded="<noscript>";
	embeded+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'";
	embeded += " width='" + width + "' height='" + height + "' id='" + swfFileName + "' align='middle'>";
	embeded+="<param name='allowScriptAccess' value='sameDomain' />";
	embeded+="<param name='allowFullScreen' value='false' />;"
	embeded += "<param name='movie' value='" + swfFileName + ".swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />	";
	embeded+="<embed src='"+ swfFileName +".swf' quality='high' bgcolor='#ffffff' ";
	embeded+="width='"+ width  +"' height='" + height + "' name='" + swfFileName + "' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	embeded += "</object></noscript>";
	document.write(embeded);
	

}
function flashMenu(pageNo) {
    AC_FL_RunContent('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
        'width', '640',
        'height', '87',
        'id', 'NavigationWhite',
        'align', 'middle',
        'src',
        'NavigationWhite',
        'quality', 'high',
        'bgcolor', '#ffffff',
        'name', 'NavigationWhite',
        'allowscriptaccess', 'sameDomain',
        'allowfullscreen', 'false',
        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
        'flashvars', 'oren=but'+pageNo,
        'movie', 'NavigationWhite');
    var embeded;
    embeded  = "<noscript>";
    embeded += "  <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'";
    embeded += "   width='640' height='87' id='NavigationWhite' align='middle'>";
    embeded += "      <param name='allowScriptAccess'  value='sameDomain' />";
    embeded += "      <param name='FlashVars'          value='oren=but" + pageNo + "'>";
    embeded += "      <param name='allowFullScreen'    value='false' />";
    embeded += "      <param name='movie'              value='NavigationWhite.swf' />";
    embeded += "      <param name='quality'            value='high' />";
    embeded += "      <param name='bgcolor'            value='#ffffff' />";
    embeded += "      <embed src='NavigationWhite.swf' ";
    embeded += "             FlashVars='oren=but" + pageNo + "'";
    embeded += "             quality='high' ";
    embeded += "             bgcolor='#ffffff'";
    embeded += "             width='640'";
    embeded += "             height='87' ";
    embeded += "             name='NavigationWhite'";
    embeded += "             align='middle' ";
    embeded += "             allowScriptAccess='sameDomain'";
    embeded += "             allowFullScreen='false' ";
    embeded += "             type='application/x-shockwave-flash' ";
    embeded += "             pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    embeded += "  </object>";
    embeded += "</noscript>";
    document.write(embeded);       
}
function postwith (to,p) {
    var myForm = document.createElement("form");
    myForm.method="post" ;
    myForm.action = to ;
    for (var k in p) {
        var myInput = document.createElement("input") ;
        myInput.setAttribute("name", k) ;
        myInput.setAttribute("value", p[k]);
        myForm.appendChild(myInput) ;
    }
    document.body.appendChild(myForm) ;
    myForm.submit() ;
    document.body.removeChild(myForm) ;
}
function flashLogin(usernameF, passwordF) {  
    postwith("../Home/", {username : usernameF, password : passwordF});
}
function hideFlash()
{
    $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
}
function visibleFlash()
{
    $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function limitTextArea(limitField, count, limitNum)
{
    alert(count);
 //   if (limitField.length > limitNum)
   // {
     //   limitField.value = limitField.value.substring(0, limitNum);
    //}
}
function checkLenth(textField, limitSize , errorLabel)
{
    if (textField.value.length > limitSize)
    {
        document.getElementById(errorLabel).style.display = 'block';
    }
    else
    {
       document.getElementById(errorLabel).style.display = 'none';
    }
}
function popupComment()
{      
    hideFlash();
    
    var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
    _docHeight += 150;
    
    var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
    Yposition = getScrollXY()[1];
    document.getElementById('hDivModalBackground').style.height = _docHeight + "px" ;
    document.getElementById('hDivModalBackground').style.display= 'block';
    document.getElementById('hDivModalPos').style.top =  Yposition+"px";
    document.getElementById('hDivModalPos').style.display= 'block';
    document.getElementById('hDivModal').style.display= 'block';
    //Effect.Grow('hDivModal', { duration: 1.0 });
    
    
}
function pausecomp(millis)
{
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 
function popupCommentClose()
{
    
    visibleFlash();
    Effect.Fade('hDivModalBackground', { duration: 1.0 });
    document.getElementById('hDivModalPos').style.display= 'none';
    document.getElementById('hDivModal').style.display = 'none';
    
}
function getScrollXY() 
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


// courtesy of http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
//********************
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
//***********************

function commentDisplay(num)
{
    var elementId = "comment" +num;
    var element = document.getElementById(elementId);
    if (element.style.display == "block")
    {
        element.style.display = "none";
    }
    else
    {
        element.style.display = "block";
    }
}
function ForumMessageDisplay(num)
{
    var elementId = "Message" + num;
    var element = document.getElementById(elementId);
    if (element.style.display == "block")
    {
        element.style.display = "none";
    }
    else
    {
        element.style.display = "block";
    }
}
function embedYouTube(youTubeCode, color1, color2)
{
    var height ="344";
    var width= "425";
    swfFileName = "http://www.youtube.com/v/" + youTubeCode + "&hl=en&fs=1&rel=0&amp;color1=0x" + color1 + "&amp;color2=0x" + color2;
    AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', width,
		'height', height,
		'src', swfFileName,
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'swfFileName',
		'bgcolor', '#ffffff',
		'name', swfFileName,
		'menu', 'true',
		'allowFullScreen', 'true',
		'allowScriptAccess', 'sameDomain',
		'movie', swfFileName,
		'textAdd', 'texti1',
		'salign', ''
			); //end AC code
	var embeded;
	embeded="<noscript>";
	embeded+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'";
	embeded += " width='" + width + "' height='" + height + "' id='" + swfFileName + "' align='middle'>";
	embeded+="<param name='allowScriptAccess' value='sameDomain' />";
	embeded+="<param name='allowFullScreen' value='false' />;"
	embeded += "<param name='movie' value='" + swfFileName + ".swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />	";
	embeded+="<param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\">";
	embeded+="<embed src='"+ swfFileName +"' quality='high' bgcolor='#ffffff' ";
	embeded+="width='"+ width  +"' height='" + height + "' name='" + swfFileName + "' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	embeded += "</object></noscript>";
    document.write(embeded);
    //var x = document.getElementById(tagID).innerHtml; //= embeded;
  //  alert(x)
	
	//<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/nNY-y2kWTcc&hl=en&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nNY-y2kWTcc&hl=en&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
}

