// POP FUNCTIONS

function popcustom(url, name, gen, yuk, sbar, resize){
	//old popup script
	eval(window.open(url,name,"toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=" + sbar + ",resizable=" + resize + ",width=" + gen + ",height=" + yuk + ",screenX=0,screenY=0,top=0,left=0"))
}
function showpopbox(object,customwidth,customheight){
	//open colorbox in iframe from A tag örnek showpopbox(this,'600px','600px');return false; -Barış
	$(object).colorbox({width:customwidth,height:customheight,open:true,iframe:true,overlayClose:false});
}
function showpopmesajgonder(object){
	$(object).colorbox({width:'500px',height:'350px',open:true,iframe:true,overlayClose:false,title:'Mesaj Gönder'});
}

function popboxclose(){
	parent.$.fn.colorbox.close();
}

function copyprot(){ //disable right click menu for copyprot class - Barış
	$('.copyprot').each( function() {
		$(this)[0].oncontextmenu = function() {
			return false;
		}
	});
}
// TRANSFORMATION FUNCTION

		var transformState = 0;
        function TransformPage(XMLPage, XSLPage, displayDiv)
        {       
            if (transformState == 0)
            {
                transformState = 1;
                
                var XML_URL = XMLPage;
                var XSL_URL = XSLPage;
                var HTML_BIND_DIV = displayDiv;
                         
                if(document.implementation && document.implementation.createDocument)
                {
                    // Mozilla
                    
                    var xsltProcessor = new XSLTProcessor();
                    var myXMLHTTPRequest = new XMLHttpRequest();
                    var xmlDoc;

                    // load xml data
                    if (XML_URL != '')
                    {
                        // load the xml file
                        myXMLHTTPRequest.open("GET", XML_URL, false);
                        myXMLHTTPRequest.send(null);
                        xmlDoc = myXMLHTTPRequest.responseText;
                    }

                    // load the xslt file                
                    myXMLHTTPRequest.open("GET", XSL_URL, false);
                    myXMLHTTPRequest.send(null);
                    // get the XSL document
                    xslStylesheet = myXMLHTTPRequest.responseText;
                    // load XSL file to XSLT processor
                    //xsltProcessor.importStylesheet(xslStylesheet);
                
                         
                    $("#" + displayDiv).xslt(xmlDoc, xslStylesheet);
//                    var resultDocument = xsltProcessor.transformToFragment(xmlDoc, xslStylesheet);
//                    
//                    $("#" + HTML_BIND_DIV)[0].innerHTML = '';   
//                    $("#" + HTML_BIND_DIV)[0].appendChild(resultDocument);
                }
                else if (window.ActiveXObject)
                {
				    // IE
    				
                    // load xml data
                    if (XML_URL != '')
                    {
                        // load the xml file
                        xml = new ActiveXObject("MSXML2.DOMDocument");
				        xml.async = false
				        xml.load(XML_URL);
                    }
                    				
				    // Load XSL
				    var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
				    xsl.async = false
				    xsl.load(XSL_URL)

                    var tem = new ActiveXObject("MSXML2.XSLTemplate");
                    tem.stylesheet = xsl;
                    var proc = tem.createProcessor();
                                      
				    // Transform
                    proc.input = xml;
                    proc.transform();
                    var str = proc.output;
    			    
                    // bind
				    document.getElementById(HTML_BIND_DIV).innerHTML=str;
			    }
			    else
			    {
				    // Browser unknown
				    alert("Browser unknown");
			    }
			    
			    transformState = 0;
			    copyprot();//image protection -baris
            }
        }
        
// TIMING FUNCTION

        function Timer()
		{	
			this.Interval 		= -1;
			this.TimerID 		= null;
			this.OnTimeout 		= null;
			this.AutoLoop 		= true;
			this.TimeoutEvent 	= null;

			var now = new Date();
			var objName = now.getMinutes() + now.getSeconds() + '_' + Math.floor(Math.random()*100);
			this.obj = "timer" + objName + "Object"; 
			eval(this.obj + "=this");
			return this;
		}
		
		Timer.prototype.SetInterval = function(intValue) { this.Interval = intValue; }
		Timer.prototype.SetTimeoutEvent = function(strCommand) { this.TimeoutEvent = strCommand; }

		Timer.prototype.Start = function() 
		{
			if (this.Interval == -1)
			{
				alert("Timer Interval Not Set!");
				return false;
			}
			else
			{ 
				this.TimerID = setTimeout(this.obj+".Timeout()",this.Interval); 
			}
		}
		Timer.prototype.Stop = function() 
		{
			if (this.TimerID != null)
			{
				clearTimeout(this.TimerID);
			}
		}
		Timer.prototype.Timeout = function () 
		{
			if (this.AutoLoop)
			{
				this.TimerID = setTimeout(this.obj+".Timeout()",this.Interval);
			}
			eval(this.TimeoutEvent);	
		}
		Timer.prototype.AutoLoop = function (blnValue) 
		{
			this.Loop = blnValue;
		}


// TRANSFORM PROFILE FUNCTIONS