//Browser Support Code
var gl_music_location =''; //Global variable to store the location
var gl_media_format =''; //Global variable to store the location    
var gl_artist =''; //Global variable to store the location    
var gl_title =''; //Global variable to store the location    
var HTML = ''; //We display the final DIV

//function createIframe (iframeName, width, height,catIDs,widgetColor) {
function createIframe (iframeName, width, height,catIDs,widgetColor,widgetColm,args,search_name) {

    var iframe = null;
    if (document.createElement && (iframe =
        document.createElement('iframe'))) {
        iframe.name = iframe.id = iframeName;
        iframe.width = width;
        iframe.height = height;
        iframe.height = height;
        iframe.background = "#fff";
        iframe.frameborder="0";
        iframe.marginwidth="0";
        iframe.marginheight="0";
        iframe.scrolling="no";
           var url='http://www.keyvive.com/';
          
           iframe.src = 'http://www.keyvive.com/jswidget/?catNames='+catIDs+'&widgetColor='+widgetColor+'&widgetColm='+widgetColm+'&search_name='+search_name+'&'+args+'&ref='+location.href;
           
        //iframe.src = 'http://staging.keyvive.com/jswidget/?catNames='+catIDs+'&widgetColor='+widgetColor+'&widgetColm='+widgetColm+'&'+args+'&ref='+location.href;
        document.getElementById('StunmediakeyviveWidget').appendChild(iframe);
        
    }

    return iframe;
}

function create_widget(widgetCatID,widgetColor,widgetColm,args,search_name) {

    //var iframe = createIframe ('iframe0',170, 448,widgetCatID,widgetColor);	
    var iframe = '';
    var arrFormat = '';
    var rowcolmFormat = '';
    var width='';
    var height='';
    var params = '';
    //alert(widgetColm);
    //rowcolmFormat = widgetColm.split('x');
    //alert('Row '+ rowcolmFormat[0] + ' - Colm ' + rowcolmFormat[1]);
    //alert(args);
    params = widgetColm.split('=');
    if( params[4] == 'large' ) { 
        switch( widgetColm ) {
                 case '1x1':
                           width = "120";
                           height = "165";
                           break;
                 case '1x2':
                           width = "208";
                           height = "165";
                           break;
                 case '1x3':
                           width = "317";
                           height = "165";
                           break;
                 case '1x4':
                           width = "392";
                           height = "165";
                           break;
                              
                 case '2x1':
                           width = "120";
                           height = "290";
                           break;
                 case '2x2':
                           width = "208";
                           height = "290";
                           break;
                 case '2x3':
                           width = "317";
                           height = "290";
                           break;
                 case '2x4':
                           width = "392";
                           height = "290";
                           break;
                 case '3x1':
                           width = "120";
                           height = "416";
                           break;
                 case '3x2':
                           width = "208";
                           height = "416";
                           break;
                 case '3x3':
                           width = "317";
                           height = "416";
                           break;
                 case '4x1':
                           width = "120";
                           height = "541";
                           break;
                 case '4x2':
                           width = "208";
                           height = "541";
                           break;              
                                                                  
                 default:
                           width = "120";
                           height = "416";
                           break;    
        }//End of switch for large
                  
    } else { //otherwise small widget
        switch( widgetColm ) {
                case '1x1':
                           width = "170";
                           height = "165";
                           break;
                case '1x2':
                           width = "295";
                           height = "165";
                           break;
                case '1x3':
                           width = "428";
                           height = "165";
                           break;
                case '1x4':
                           width = "570";
                           height = "165";
                           break;
                case '2x1':
                           width = "170";
                           height = "287";
                           break;
                case '2x2':
                           width = "295";
                           height = "287";
                           break;
                case '2x3':
                          width = "428";
                          height = "287";
                          break;
                case '2x4':
                          width = "570";
                          height = "287";
                          break;
                case '3x1':
                          width = "170";
                          height = "416";
                          break;
                case '3x2':
                          width = "295";
                          height = "416";
                          break;
                case '3x3':
                          width = "428";
                          height = "416";
                          break;
                case '4x1':
                          width = "170";
                          height = "541";
                          break;
                case '4x2':
                          width = "293";
                          height = "541";
                          break;              
                default:
                          width = "170";
                          height = "416";
                          break;    
        }//End of switch for large
    } 
  // customizeWidgetImgSize('StunmediakeyviveWidget','3x1',document.widgetFrm.chkCategories,document.getElementById('widgetImgSizeProp').value,document.getElementById('widgetOverallColors').value); 
    //alert('Width '+width+' Height '+height+' Category ID'+widgetCatID+' Widget Color '+widgetColor+' Colmns '+widgetColm);
 
    //iframe = createIframe ('iframe0',170, 448,widgetCatID,widgetColor);
    var iframe = null;
    iframe = createIframe ('iframe0',width,height,widgetCatID,widgetColor,widgetColm,args,search_name);
    document.getElementById('iframe0').style.border="none";
         
    if (iframe)
    {
		    var iframeDoc = null;
		    if (iframe.contentDocument) {
			     iframeDoc = iframe.contentDocument;
		    } else if (iframe.contentWindow) {
			     iframeDoc = iframe.contentWindow.document;
		    }	else if (window.frames[iframe.name]) {
			     iframeDoc = window.frames[iframe.name].document;
		    }//End of if condition
		    
		    if(iframeDoc == null)
		      throw "Document not initialized";
	 }  //End of if condition
}//End of function create widget

try {
    //var BHW_format = '230x448';
    create_widget(BHW_catID,BHW_color,BHW_rowcolm,BHW_args,search_name);
} catch(paramsErr) {
    var BHW_catID = '@';
    var BHW_color = '336597';
    var BHW_rowcolm = '3x1';
    var BHW_args = 'imgSize=large&headerFooter=336597&bg=EEEEEE&text=F15922&headerFooterText=336597';
    var search_name = '';
    create_widget(BHW_catID,BHW_color,BHW_rowcolm,BHW_args,search_name);
}     
